Commit 04831a29 authored by Alex Moore's avatar Alex Moore
Browse files

initial system integration largely complete - just some minor tweaks for...

initial system integration largely complete - just some minor tweaks for tomorrow.  here goes nothing.
parent d4ef9e41
(function() {
var user = document.getElementById("UserID"); // User ID input
var pword = document.getElementById("Password"); // Password input
var type = document.getElementsByName("ScanType"); // Scan or Identify missing Radiobuttons
var inventory = document.getElementById("InventoryRadioBtn");
var missing = document.getElementById("IDMissingRadioBtn");
\ No newline at end of file
GetLocation();
var loc = document.getElementById("LocationSelCtl"); // Location select
loc.selectedIndex = 2; // Make sure this is the Lewisburg branch
loc.value = loc.options[2].value;
inventory.checked = true;
doLogin();
})();
\ No newline at end of file
......@@ -40,6 +40,8 @@
EF620A2C1ABA4BFD009E7B46 /* WhatPage.js in Resources */ = {isa = PBXBuildFile; fileRef = EF620A201ABA4BFD009E7B46 /* WhatPage.js */; };
EF80050A1AB9E1E200A10D56 /* SectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EF8005091AB9E1E200A10D56 /* SectionViewController.m */; };
EF80050D1ABA122E00A10D56 /* GlobalWebController.m in Sources */ = {isa = PBXBuildFile; fileRef = EF80050C1ABA122E00A10D56 /* GlobalWebController.m */; };
EFAB8E001ABBB129001F0526 /* Login1.js in Resources */ = {isa = PBXBuildFile; fileRef = EFAB8DFF1ABBB129001F0526 /* Login1.js */; };
EFAB8E021ABBB137001F0526 /* Login2.js in Resources */ = {isa = PBXBuildFile; fileRef = EFAB8E011ABBB137001F0526 /* Login2.js */; };
EFF4A0F31AB9110800FA82F3 /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EFF4A0F21AB9110800FA82F3 /* WebViewController.m */; };
/* End PBXBuildFile section */
......@@ -102,6 +104,8 @@
EF8005091AB9E1E200A10D56 /* SectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SectionViewController.m; sourceTree = "<group>"; };
EF80050B1ABA122E00A10D56 /* GlobalWebController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlobalWebController.h; sourceTree = "<group>"; };
EF80050C1ABA122E00A10D56 /* GlobalWebController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GlobalWebController.m; sourceTree = "<group>"; };
EFAB8DFF1ABBB129001F0526 /* Login1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = Login1.js; sourceTree = "<group>"; };
EFAB8E011ABBB137001F0526 /* Login2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = Login2.js; sourceTree = "<group>"; };
EFF4A0F11AB9110800FA82F3 /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewController.h; sourceTree = "<group>"; };
EFF4A0F21AB9110800FA82F3 /* WebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewController.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -254,6 +258,8 @@
EF620A1A1ABA4BFD009E7B46 /* GetSelectedCollections.js */,
EF620A1B1ABA4BFD009E7B46 /* GoToScan.js */,
EF620A1C1ABA4BFD009E7B46 /* Login.js */,
EFAB8DFF1ABBB129001F0526 /* Login1.js */,
EFAB8E011ABBB137001F0526 /* Login2.js */,
EF620A1D1ABA4BFD009E7B46 /* RemoveCollection.js */,
EF620A1E1ABA4BFD009E7B46 /* SaveSetup.js */,
EF620A1F1ABA4BFD009E7B46 /* ScanBarcode.js */,
......@@ -353,12 +359,14 @@
EF620A281ABA4BFD009E7B46 /* Login.js in Resources */,
78FD6B381A817F4500D48A92 /* greencheck.png in Resources */,
EF620A291ABA4BFD009E7B46 /* RemoveCollection.js in Resources */,
EFAB8E001ABBB129001F0526 /* Login1.js in Resources */,
78FD6B3A1A817F4D00D48A92 /* redx.png in Resources */,
EF620A261ABA4BFD009E7B46 /* GetSelectedCollections.js in Resources */,
78FD6B1C1A81713A00D48A92 /* LaunchScreen.xib in Resources */,
EF620A231ABA4BFD009E7B46 /* GetAvailableCollections.js in Resources */,
784F46F31A83CF7D00EAC872 /* greyx2.png in Resources */,
EF620A2A1ABA4BFD009E7B46 /* SaveSetup.js in Resources */,
EFAB8E021ABBB137001F0526 /* Login2.js in Resources */,
EF620A241ABA4BFD009E7B46 /* GetError.js in Resources */,
EF620A2B1ABA4BFD009E7B46 /* ScanBarcode.js in Resources */,
78FD6B191A81713A00D48A92 /* Images.xcassets in Resources */,
......
......@@ -11,8 +11,8 @@
@interface LogInViewController : WebViewController
@property (weak, nonatomic, readonly) UIButton *btnLogIn;
@property (weak, nonatomic, readonly) UITextField *txtUsername;
@property (weak, nonatomic, readonly) UITextField *txtPassword;
@property (weak, nonatomic, readwrite) UITextField *txtUsername;
@property (weak, nonatomic, readwrite) UITextField *txtPassword;
@end
......@@ -9,19 +9,19 @@
#import "LogInViewController.h"
@interface LogInViewController ()
@property (weak, nonatomic, readwrite) IBOutlet UITextField *txtUsername;
@property (weak, nonatomic, readwrite) IBOutlet UITextField *txtPassword;
- (IBAction)btnLogInTouch:(id)sender;
//@property (weak, nonatomic, readwrite) IBOutlet UITextField *txtUsername;
//@property (weak, nonatomic, readwrite) IBOutlet UITextField *txtPassword;
//- (IBAction)btnLogInTouch:(id)sender;
@end
@implementation LogInViewController
@synthesize txtUsername;
@synthesize txtPassword;
//@synthesize txtUsername;
//@synthesize txtPassword;
static NSString *USERNAME = @"";//@"alex";
static NSString *PASSWORD = @"";//@"what";
//static NSString *USERNAME = @"";//@"alex";
//static NSString *PASSWORD = @"";//@"what";
- (void)viewDidLoad {
[super viewDidLoad];
......@@ -63,30 +63,71 @@ static NSString *PASSWORD = @"";//@"what";
*/
- (IBAction)btnLogInTouch:(id)sender {
//Login to page when button is pressed
// NSString *loginPath =
// [[NSBundle mainBundle] pathForResource:@"Login" ofType:@"js"];
// NSString *login = [NSString stringWithContentsOfFile:loginPath
// encoding:NSUTF8StringEncoding
// error:nil];
//
// NSString *success =
// [self.webview stringByEvaluatingJavaScriptFromString:login];
//
// UIAlertView *loginAlert = [[UIAlertView alloc] initWithTitle:@"Logged In!"
// message:success
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
// [loginAlert show];
// NSString *path =
// [[NSBundle mainBundle] pathForResource:@"WhatPage" ofType:@"js"];
// NSString *content = [NSString stringWithContentsOfFile:path
// encoding:NSUTF8StringEncoding
// error:nil];
//
// NSString *page =
// [self.webview stringByEvaluatingJavaScriptFromString:content];
// NSLog(@"PAGE NUMBER IS: %@\n", page);
//
// if ([page isEqual:@"0"]) { // Login Page
// NSString *loginPath =
// [[NSBundle mainBundle] pathForResource:@"Login" ofType:@"js"];
// NSString *login = [NSString stringWithContentsOfFile:loginPath
// encoding:NSUTF8StringEncoding
// error:nil];
//
// NSString *success =
// [self.webview stringByEvaluatingJavaScriptFromString:login];
//
// UIAlertView *loginAlert = [[UIAlertView alloc] initWithTitle:@"Logged In!"
// message:success
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
// [loginAlert show];
// }
NSString *login1Path =
[[NSBundle mainBundle] pathForResource:@"Login1" ofType:@"js"];
NSString *login1 = [NSString stringWithContentsOfFile:login1Path
encoding:NSUTF8StringEncoding
error:nil];
NSString *login2Path =
[[NSBundle mainBundle] pathForResource:@"Login2" ofType:@"js"];
NSString *login2 = [NSString stringWithContentsOfFile:login2Path
encoding:NSUTF8StringEncoding
error:nil];
NSString *username = @"user.value = \"";
username = [username stringByAppendingString:[self.txtUsername.text stringByAppendingString:@"\";"]];
if([txtUsername.text isEqualToString: USERNAME] && [txtPassword.text isEqualToString:PASSWORD]) {//check username and password
NSString *password = @"pword.value = \"";
password = [password stringByAppendingString:[self.txtPassword.text stringByAppendingString:@"\";"]];
NSString *login = [login1 stringByAppendingString:[username stringByAppendingString:[password stringByAppendingString:login2]]];
NSLog(@"%@", login);
NSString *success =
[self.webview stringByEvaluatingJavaScriptFromString:login];
// UIAlertView *loginAlert = [[UIAlertView alloc] initWithTitle:@"Logged In!"
// message:success
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
// [loginAlert show];
//For testing
if([self.txtUsername.text isEqualToString:@"circ_admin"] && [self.txtPassword.text isEqualToString:@"silver"]) {//check username and password
[self performSegueWithIdentifier:@"segueLogIn" sender:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Incorrect login" message:@"Username or password incorrect" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
}
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="Feu-98-wZh">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="juL-Mo-vpA">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
......@@ -212,48 +211,63 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" image="greyx2.png" translatesAutoresizingMaskIntoConstraints="NO" id="ybW-ia-BeV">
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="greyx2.png" translatesAutoresizingMaskIntoConstraints="NO" id="ybW-ia-BeV">
<rect key="frame" x="484" y="236" width="100" height="100"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="AuY-g2-4Kj"/>
<constraint firstAttribute="height" constant="100" id="gZ3-Rw-3sh"/>
<constraint firstAttribute="width" constant="100" id="6aa-qB-emQ"/>
</constraints>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" image="greycheck2.png" translatesAutoresizingMaskIntoConstraints="NO" id="ROA-6e-Pjx">
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="greycheck2.png" translatesAutoresizingMaskIntoConstraints="NO" id="ROA-6e-Pjx">
<rect key="frame" x="16" y="236" width="100" height="100"/>
<accessibility key="accessibilityConfiguration">
<accessibilityTraits key="traits" none="YES" image="YES" notEnabled="YES"/>
</accessibility>
<constraints>
<constraint firstAttribute="width" secondItem="ROA-6e-Pjx" secondAttribute="height" multiplier="1:1" id="R3t-B2-iK5"/>
<constraint firstAttribute="width" constant="100" id="SQY-vq-8sJ"/>
<constraint firstAttribute="height" constant="100" id="WvI-LR-IXy"/>
<constraint firstAttribute="height" constant="100" id="5Li-kc-WoG"/>
<constraint firstAttribute="width" constant="100" id="MUy-Z2-sQ3"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="28C-Wr-Ey7">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="28C-Wr-Ey7">
<rect key="frame" x="273" y="92" width="42" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="H7S-u0-5kF">
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="H7S-u0-5kF">
<rect key="frame" x="10" y="145" width="568" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" allowsSelectionDuringEditing="YES" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="HXe-Ct-PRX">
<rect key="frame" x="16" y="344" width="568" height="236"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ListPrototypeCell" id="R2Y-bl-AZc">
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="R2Y-bl-AZc" id="gTB-qj-Bj6">
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="ROA-6e-Pjx" firstAttribute="leading" secondItem="STn-V1-lxQ" secondAttribute="leadingMargin" id="0hg-2s-05T"/>
<constraint firstAttribute="centerX" secondItem="28C-Wr-Ey7" secondAttribute="centerX" id="AbP-uv-U7T"/>
<constraint firstAttribute="centerY" secondItem="ybW-ia-BeV" secondAttribute="centerY" id="DPh-IR-Amw"/>
<constraint firstItem="H7S-u0-5kF" firstAttribute="top" secondItem="RKt-M1-hEG" secondAttribute="bottom" constant="79" id="Gsk-Gj-A38"/>
<constraint firstAttribute="centerX" secondItem="H7S-u0-5kF" secondAttribute="centerX" id="IJw-1h-Lbr"/>
<constraint firstItem="ybW-ia-BeV" firstAttribute="trailing" secondItem="STn-V1-lxQ" secondAttribute="trailingMargin" id="XKy-lj-sEj"/>
<constraint firstAttribute="centerY" secondItem="ROA-6e-Pjx" secondAttribute="centerY" id="Y2V-Vb-6pH"/>
<constraint firstItem="H7S-u0-5kF" firstAttribute="leading" secondItem="STn-V1-lxQ" secondAttribute="leadingMargin" id="gKw-XQ-QYf"/>
<constraint firstItem="28C-Wr-Ey7" firstAttribute="top" secondItem="RKt-M1-hEG" secondAttribute="bottom" constant="28" id="pKn-8w-jNK"/>
<constraint firstItem="H7S-u0-5kF" firstAttribute="trailing" secondItem="STn-V1-lxQ" secondAttribute="trailingMargin" id="vfi-d3-lh3"/>
<constraint firstItem="HXe-Ct-PRX" firstAttribute="trailing" secondItem="STn-V1-lxQ" secondAttribute="trailingMargin" id="99M-vq-Cfy"/>
<constraint firstItem="H7S-u0-5kF" firstAttribute="top" secondItem="28C-Wr-Ey7" secondAttribute="bottom" constant="32" id="F6h-P3-8IZ"/>
<constraint firstAttribute="trailingMargin" secondItem="H7S-u0-5kF" secondAttribute="trailing" constant="6" id="IjG-FN-Wci"/>
<constraint firstItem="ROA-6e-Pjx" firstAttribute="leading" secondItem="STn-V1-lxQ" secondAttribute="leadingMargin" id="JBZ-nT-yWm"/>
<constraint firstItem="ROA-6e-Pjx" firstAttribute="top" secondItem="ybW-ia-BeV" secondAttribute="top" id="a4o-AO-cnn"/>
<constraint firstItem="ROA-6e-Pjx" firstAttribute="leading" secondItem="HXe-Ct-PRX" secondAttribute="leading" id="dbS-ZC-BYY"/>
<constraint firstAttribute="bottom" secondItem="HXe-Ct-PRX" secondAttribute="bottom" constant="20" symbolic="YES" id="en6-zH-p3j"/>
<constraint firstItem="28C-Wr-Ey7" firstAttribute="top" secondItem="RKt-M1-hEG" secondAttribute="bottom" constant="28" id="fQZ-8a-AdG"/>
<constraint firstItem="H7S-u0-5kF" firstAttribute="leading" secondItem="STn-V1-lxQ" secondAttribute="leadingMargin" constant="-6" id="puB-2B-OC7"/>
<constraint firstItem="HXe-Ct-PRX" firstAttribute="top" secondItem="ybW-ia-BeV" secondAttribute="bottom" constant="8" symbolic="YES" id="rNB-qF-5Nj"/>
<constraint firstItem="H7S-u0-5kF" firstAttribute="centerX" secondItem="28C-Wr-Ey7" secondAttribute="centerX" id="tiY-W0-ad1"/>
<constraint firstItem="ROA-6e-Pjx" firstAttribute="top" secondItem="H7S-u0-5kF" secondAttribute="bottom" constant="61" id="utw-to-uqn"/>
<constraint firstItem="HXe-Ct-PRX" firstAttribute="top" secondItem="ROA-6e-Pjx" secondAttribute="bottom" constant="8" symbolic="YES" id="wZa-0y-miV"/>
<constraint firstItem="ybW-ia-BeV" firstAttribute="trailing" secondItem="HXe-Ct-PRX" secondAttribute="trailing" id="yuo-Qk-kul"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="Scan Book ID" id="3KX-LL-wsG">
......@@ -267,6 +281,7 @@
<outlet property="imgCheck" destination="ROA-6e-Pjx" id="aHt-g1-AhY"/>
<outlet property="imgX" destination="ybW-ia-BeV" id="13c-F3-Ox4"/>
<outlet property="lblSection" destination="28C-Wr-Ey7" id="xrK-eJ-KDa"/>
<outlet property="scannedBookTableView" destination="HXe-Ct-PRX" id="PAx-2H-PL6"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="cQa-49-Hhu" userLabel="First Responder" sceneMemberID="firstResponder"/>
......
......@@ -10,11 +10,12 @@
#import "Session.h"
#import "CaptuvoScannerController.h"
@interface ScanBookViewController : CaptuvoScannerController
@interface ScanBookViewController : CaptuvoScannerController<UITableViewDataSource, UITableViewDelegate>
@property Session *session;
@property UIWebView *webview;
@property (nonatomic) BOOL contScan;
@property (nonatomic) int volume;
@property (weak, nonatomic) IBOutlet UITableView *scannedBookTableView;
@end
......@@ -18,6 +18,11 @@ static int BOOK_ID_LENGTH = 14;
@property (weak, nonatomic) IBOutlet UIImageView *imgCheck;
@property (weak, nonatomic) IBOutlet UIImageView *imgX;
@property (weak, nonatomic) IBOutlet UILabel *lblSection;
@property NSMutableArray *scannedBookList;
@property NSMutableArray *idList;
@property NSMutableArray *callNumList;
@property NSMutableArray *titleList;
- (void)txtChange;
......@@ -37,15 +42,24 @@ static int BOOK_ID_LENGTH = 14;
[super viewDidLoad];
// Do any additional setup after loading the view.
lblSection.text = session.section;
[self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(endEditing:)]];
//[self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(endEditing:)]];
// SEND SESSION TO RTI
//self.navigationItem.hidesBackButton = YES;
self.scannedBookList = [[NSMutableArray alloc] init];
self.idList = [[NSMutableArray alloc] init];
self.callNumList = [[NSMutableArray alloc] init];
self.titleList = [[NSMutableArray alloc] init];
GlobalWebController *globalWeb = [GlobalWebController getInstance];
self.webview = globalWeb.web;
[self.view addSubview:self.webview];
self.scannedBookTableView.delegate = self;
self.scannedBookTableView.dataSource = self;
[self.scannedBookTableView reloadData];
//For testing
[self.webview loadRequest:[NSURLRequest requestWithURL: [NSURL
URLWithString:@"file:///Users/plucseniordesign/Desktop/RTIScan2/RTIScan2.html"]]];
}
-(void) viewDidAppear:(BOOL)animated {
......@@ -56,13 +70,73 @@ static int BOOK_ID_LENGTH = 14;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[super webViewDidFinishLoad:webView];
NSURLRequest *currentRequest = [webView request];
NSURL *currentURL = [currentRequest URL];
NSLog(@"2: Current URL is %@", currentURL.absoluteString);
// Get scanned codes - Testing GetScanned
NSString *getScanPath =
[[NSBundle mainBundle] pathForResource:@"GetScanned" ofType:@"js"];
NSString *getScan = [NSString stringWithContentsOfFile:getScanPath
encoding:NSUTF8StringEncoding
error:nil];
NSString *scanned =
[webView stringByEvaluatingJavaScriptFromString:getScan];
//self.bookLog.text = scanned;
NSLog(@"%@", scanned);
// UIAlertView *previousScan =
// [[UIAlertView alloc] initWithTitle:@"Previous Scans"
// message:scanned
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
//
// [previousScan show];
[self extractInformation:scanned];
}
- (void)extractInformation:(NSString *)scannedBooks {
//Clear lists
[self.idList removeAllObjects];
[self.callNumList removeAllObjects];
[self.titleList removeAllObjects];
//Extract book ID
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\"id\"\\:\"([0-9]*)\"" options:0 error: Nil];
NSArray *rangeList = [regex matchesInString:scannedBooks options:0 range:NSMakeRange(0, [scannedBooks length])];
for(NSTextCheckingResult *range in rangeList) {
[self.idList addObject:[scannedBooks substringWithRange:[range rangeAtIndex:1]]];
}
//Extract book call number
regex = [NSRegularExpression regularExpressionWithPattern:@"\"callnum\"\\:\"([0-9a-zA-Z\\.]*)\"" options:0 error: Nil];
rangeList = [regex matchesInString:scannedBooks options:0 range:NSMakeRange(0, [scannedBooks length])];
for(NSTextCheckingResult *range in rangeList) {
[self.callNumList addObject:[scannedBooks substringWithRange:[range rangeAtIndex:1]]];
}
//Extract book title
regex = [NSRegularExpression regularExpressionWithPattern:@"\"title\"\\:\"([0-9a-zA-Z\\.\\&\\;]*)\"" options:0 error: Nil];
rangeList = [regex matchesInString:scannedBooks options:0 range:NSMakeRange(0, [scannedBooks length])];
NSString *title;
for(NSTextCheckingResult *range in rangeList) {
title = [scannedBooks substringWithRange:[range rangeAtIndex:1]];
[self.titleList addObject:[scannedBooks substringWithRange:[range rangeAtIndex:1]]];
}
//Populate table view
NSLog(@"num scanned books = %d", [self.idList count]);
for(int i = 0; i < [self.idList count]; i++) {
NSLog(@"%@, %@, %@", [self.idList objectAtIndex:i], [self.callNumList objectAtIndex:i], [self.titleList objectAtIndex:i]);
[self.scannedBookList addObject:[self.idList objectAtIndex:i]];
}
[self.scannedBookTableView reloadData];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
......@@ -81,6 +155,43 @@ static int BOOK_ID_LENGTH = 14;
return NO; // Unknown value
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [self.idList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ListPrototypeCell" forIndexPath:indexPath];
// Configure the cell...
NSString *scannedBook = [self.scannedBookList objectAtIndex:indexPath.row];
cell.textLabel.text = scannedBook;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *bookID = [self.idList objectAtIndex:indexPath.row];
NSString *callNum = [self.callNumList objectAtIndex:indexPath.row];
NSString *title = [self.titleList objectAtIndex:indexPath.row];
NSString *message = [NSString stringWithFormat:@"Book ID: %@\nCall Number: %@\nTitle: %@\n", bookID, callNum, title];
UIAlertView *messageAlert = [[UIAlertView alloc]
initWithTitle:@"Book details" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
// Display Alert Message
[messageAlert show];
[tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:NO];
}
#pragma mark - Navigation
......@@ -133,17 +244,31 @@ static int BOOK_ID_LENGTH = 14;
if(self.txtBookID.text.length == BOOK_ID_LENGTH) { //string is proper length
if([self.txtBookID.text rangeOfCharacterFromSet:notDigits].location == NSNotFound) { //string is numeric
// SEND BOOK ID TO RTI
NSString *barcode = self.txtBookID.text;
NSString *stringStart = @"var code = '";
NSString *stringEnd = @"';";
NSString *newString = [stringStart stringByAppendingString:barcode];
NSString *inputCode = [newString stringByAppendingString:stringEnd];
//randomly generate errors
int random = arc4random() % 10;
if(random < 5) {
//green check
[self changeCheckImage];
} else {
//red x
[self changeXImage];
}
NSString *scanPath =
[[NSBundle mainBundle] pathForResource:@"ScanBarcode" ofType:@"js"];
NSString *scan = [NSString stringWithContentsOfFile:scanPath
encoding:NSUTF8StringEncoding
error:nil];
[self.webview stringByEvaluatingJavaScriptFromString:inputCode];
[self.webview stringByEvaluatingJavaScriptFromString:scan];
// //randomly generate errors
// int random = arc4random() % 10;
// if(random < 5) {
// //green check
// [self changeCheckImage];
//
// } else {
// //red x
// [self changeXImage];
// }
} else {
......@@ -151,7 +276,9 @@ static int BOOK_ID_LENGTH = 14;
[alert show];
}
} else {
//if not 13 digits
//if not 14 digits
//UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid Book ID" message:@"Book ID improper length" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
//[alert show];
}
}
......
......@@ -10,7 +10,7 @@
#import "Session.h"
#import "ScanBookViewController.h"
@interface SectionViewController : WebViewController <UITableViewDataSource, UITableViewDelegate, UIWebViewDelegate>
@interface SectionViewController : WebViewController <UITableViewDataSource, UITableViewDelegate>//, UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView ;
@end
......@@ -20,8 +20,6 @@
@implementation SectionViewController
bool firstLoad = true;
- (void)viewDidLoad {
[super viewDidLoad];
......@@ -33,48 +31,21 @@ bool firstLoad = true;
self.sections = [[NSMutableArray alloc] init];
self.tableView.delegate = self;
self.tableView.dataSource = self;
//[self loadInitialData];
[self getCollections];
[self.tableView reloadData];
//set up uiwebview
// if (firstLoad) {
// self.webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
// GlobalWebController *globalWeb = [GlobalWebController getInstance];
// globalWeb.web = self.webview;
//
// self.webview.delegate = self;
// NSString *fullURL = @"http://www.google.com";
// NSURL *url = [NSURL URLWithString:fullURL];
// NSURLRequest *request = [NSURLRequest requestWithURL:url];
// //self.webview.scalesPageToFit = YES;
// [self.webview loadRequest:request];
// [self.view addSubview:self.webview];
// firstLoad = false;
// }
//For testing
[self.webview loadRequest:[NSURLRequest requestWithURL: [NSURL
URLWithString:@"file:///Users/plucseniordesign/Desktop/RTISetup.html"]]];
}
- (void)viewDidAppear:(BOOL)animated {
NSLog(@"viewDidAppear");