Commit 690104ba authored by Alex Moore's avatar Alex Moore
Browse files

updated scan page with finish button

parent 04831a29
No preview for this file type
This diff is collapsed.
......@@ -10,6 +10,6 @@
@interface CaptuvoScannerController : CaptuvoViewController
//@property (weak, nonatomic) IBOutlet UITextField *txtBookID;
@property (weak, nonatomic) IBOutlet UITextField *txtBookID;
@end
......@@ -211,35 +211,16 @@
<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" 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="6aa-qB-emQ"/>
</constraints>
</imageView>
<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="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" 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" 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"/>
<rect key="frame" x="16" y="145" width="568" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<action selector="txtChange:" destination="chc-VY-Gqa" eventType="editingChanged" id="8Fd-OM-q60"/>
</connections>
</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"/>
<rect key="frame" x="16" y="226" width="568" height="284"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ListPrototypeCell" id="R2Y-bl-AZc">
......@@ -251,23 +232,35 @@
</tableViewCell>
</prototypes>
</tableView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gwd-yc-1oH">
<rect key="frame" x="280" y="550" width="41" height="30"/>
<state key="normal" title="Finish">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="clickedFinish:" destination="chc-VY-Gqa" eventType="touchUpInside" id="Fll-P4-lsd"/>
</connections>
</button>
<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="279" y="92" width="42" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<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"/>
<constraint firstAttribute="bottom" secondItem="gwd-yc-1oH" secondAttribute="bottom" constant="20" symbolic="YES" id="2lE-Ot-r7f"/>
<constraint firstItem="HXe-Ct-PRX" firstAttribute="leading" secondItem="H7S-u0-5kF" secondAttribute="leading" id="5Go-g1-L1t"/>
<constraint firstItem="HXe-Ct-PRX" firstAttribute="top" secondItem="H7S-u0-5kF" secondAttribute="bottom" constant="51" id="GMk-lU-G2y"/>
<constraint firstItem="28C-Wr-Ey7" firstAttribute="top" secondItem="RKt-M1-hEG" secondAttribute="bottom" constant="28" id="Qbt-tQ-6A9"/>
<constraint firstItem="H7S-u0-5kF" firstAttribute="trailing" secondItem="STn-V1-lxQ" secondAttribute="trailingMargin" id="UsF-us-vpu"/>
<constraint firstItem="H7S-u0-5kF" firstAttribute="top" secondItem="28C-Wr-Ey7" secondAttribute="bottom" constant="32" id="XMR-K5-eQR"/>
<constraint firstItem="gwd-yc-1oH" firstAttribute="top" secondItem="HXe-Ct-PRX" secondAttribute="bottom" constant="40" id="hm0-Ot-mlm"/>
<constraint firstItem="HXe-Ct-PRX" firstAttribute="trailing" secondItem="H7S-u0-5kF" secondAttribute="trailing" id="pWz-7j-ZX0"/>
<constraint firstItem="28C-Wr-Ey7" firstAttribute="trailing" secondItem="gwd-yc-1oH" secondAttribute="trailing" id="uL9-yB-jnS"/>
<constraint firstItem="H7S-u0-5kF" firstAttribute="leading" secondItem="STn-V1-lxQ" secondAttribute="leadingMargin" id="wV8-Zy-euO"/>
<constraint firstItem="28C-Wr-Ey7" firstAttribute="centerX" secondItem="H7S-u0-5kF" secondAttribute="centerX" id="zQc-Zb-gYd"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="Scan Book ID" id="3KX-LL-wsG">
......@@ -278,10 +271,10 @@
</barButtonItem>
</navigationItem>
<connections>
<outlet property="imgCheck" destination="ROA-6e-Pjx" id="aHt-g1-AhY"/>
<outlet property="imgX" destination="ybW-ia-BeV" id="13c-F3-Ox4"/>
<outlet property="finishBtn" destination="gwd-yc-1oH" id="m9n-0A-U6G"/>
<outlet property="lblSection" destination="28C-Wr-Ey7" id="xrK-eJ-KDa"/>
<outlet property="scannedBookTableView" destination="HXe-Ct-PRX" id="PAx-2H-PL6"/>
<outlet property="txtBookID" destination="H7S-u0-5kF" id="B86-dX-yWV"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="cQa-49-Hhu" userLabel="First Responder" sceneMemberID="firstResponder"/>
......@@ -307,8 +300,4 @@
<point key="canvasLocation" x="194" y="136"/>
</scene>
</scenes>
<resources>
<image name="greycheck2.png" width="300" height="230"/>
<image name="greyx2.png" width="300" height="300"/>
</resources>
</document>
......@@ -17,5 +17,7 @@
@property (nonatomic) BOOL contScan;
@property (nonatomic) int volume;
@property (weak, nonatomic) IBOutlet UITableView *scannedBookTableView;
//@property (weak, nonatomic) IBOutlet UITextField *txtBookID;
@property (weak, nonatomic) IBOutlet UIButton *finishBtn;
@end
......@@ -23,7 +23,7 @@ static int BOOK_ID_LENGTH = 14;
@property NSMutableArray *idList;
@property NSMutableArray *callNumList;
@property NSMutableArray *titleList;
- (void)txtChange;
- (IBAction)txtChange:(id)sender;
......@@ -37,7 +37,6 @@ static int BOOK_ID_LENGTH = 14;
@synthesize imgCheck;
@synthesize imgX;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
......@@ -235,12 +234,8 @@ static int BOOK_ID_LENGTH = 14;
});
}
//- (IBAction)txtChange:(id)sender {
- (void)txtChange {
- (IBAction)txtChange:(id)sender {
NSCharacterSet* notDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
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
......@@ -269,7 +264,12 @@ static int BOOK_ID_LENGTH = 14;
// //red x
// [self changeXImage];
// }
NSLog(@"ID accepted");
self.view.backgroundColor = [UIColor greenColor];
[UIView animateWithDuration:1.0 animations:^{
self.view.backgroundColor = [UIColor whiteColor];
}];
[self.txtBookID setText:@""];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid Book ID" message:@"Book ID must be numeric" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
......@@ -282,11 +282,39 @@ static int BOOK_ID_LENGTH = 14;
}
}
- (void)decoderDataReceived:(NSString *)data {
[super decoderDataReceived:data];
[self txtChange];
- (IBAction)clickedFinish:(id)sender {
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);
// Test FinishScan
if ([page isEqual:@"2"]) { // Scan Page
NSString *finishPath =
[[NSBundle mainBundle] pathForResource:@"FinishScan" ofType:@"js"];
NSString *finish = [NSString stringWithContentsOfFile:finishPath
encoding:NSUTF8StringEncoding
error:nil];
NSString *isFinished =
[self.webview stringByEvaluatingJavaScriptFromString:finish];
if ([isFinished isEqual:@"-1"]) {
} else {
NSLog(@"FINISHED NOT FAILED\n");
}
}
}
//- (void)decoderDataReceived:(NSString *)data {
// [super decoderDataReceived:data];
// [self textChange];
//}
@end
......@@ -201,13 +201,13 @@
NSString *selected =
[self.webview stringByEvaluatingJavaScriptFromString:selectedFunc];
UIAlertView *selectedAlert =
[[UIAlertView alloc] initWithTitle:@"Collections Selected"
message:selected
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[selectedAlert show];
// UIAlertView *selectedAlert =
// [[UIAlertView alloc] initWithTitle:@"Collections Selected"
// message:selected
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
// [selectedAlert show];
}
......
......@@ -10,9 +10,10 @@
@interface WebViewController : UIViewController<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UITextField *txtBookID;
//@property (weak, nonatomic, readwrite) IBOutlet UITextField *txtUsername;
//@property (weak, nonatomic, readwrite) IBOutlet UITextField *txtPassword;
@property UIWebView *webview;
@end
......@@ -10,12 +10,15 @@
#import "GlobalWebController.h"
@interface WebViewController ()
@property NSString *page;
@property NSString *prevPage;
@end
@implementation WebViewController
//@synthesize txtUsername;
//@synthesize txtPassword;
@synthesize page;
@synthesize prevPage;
- (void)viewDidLoad {
[super viewDidLoad];
......@@ -53,46 +56,26 @@
- (void)webViewDidFinishLoad:(UIWebView *)webView {
// Strictly for debugging purposes
[webView stringByEvaluatingJavaScriptFromString:@"var test1 = 'Hello Pluto'"];
NSString *newHtml = [webView stringByEvaluatingJavaScriptFromString:@"test1"];
NSLog(@"%@\n", newHtml);
//[webView stringByEvaluatingJavaScriptFromString:@"var test1 = 'Hello Pluto'"];
//NSString *newHtml = [webView stringByEvaluatingJavaScriptFromString:@"test1"];
//NSLog(@"%@\n", newHtml);
NSString *path =
[[NSBundle mainBundle] pathForResource:@"WhatPage" ofType:@"js"];
NSString *content = [NSString stringWithContentsOfFile:path
encoding:NSUTF8StringEncoding
error:nil];
NSString *page = [webView stringByEvaluatingJavaScriptFromString:content];
//prevPage = page;
page = [webView stringByEvaluatingJavaScriptFromString:content];
NSLog(@"PAGE NUMBER IS: %@\n", page);
//NSLog(@"PREV PAGE NUMBER IS: %@", prevPage);
if ([page isEqual:@"0"]) { //Login Page
NSLog(@"Login");
}
else if ([page isEqual:@"1"]) { // Setup Page
NSLog(@"Setup");
} else if ([page isEqual:@"2"]) { // Scan Page
NSLog(@"Scan");
// 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;
//
// UIAlertView *previousScan =
// [[UIAlertView alloc] initWithTitle:@"Previous Scans"
// message:scanned
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
//
// [previousScan show];
} else if ([page isEqual:@"3"]) { // Error/Action Page
NSLog(@"Error");
// Get the error - Testing GetError
......@@ -104,6 +87,11 @@
NSString *error = [webView stringByEvaluatingJavaScriptFromString:getError];
self.view.backgroundColor = [UIColor redColor];
[UIView animateWithDuration:1.0 animations:^{
self.view.backgroundColor = [UIColor whiteColor];
}];
// Continue - Testing GoToScan
NSString *goToScanPath =
[[NSBundle mainBundle] pathForResource:@"GoToScan" ofType:@"js"];
......@@ -122,120 +110,6 @@
}
}
- (IBAction)scanBtnPressed:(id)sender {
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:@"2"]) { // Scan Page
// Get scanned codes - Testing GetScanned
// NSString *barcode = self.txtBookID.text;
//
// if (barcode.length != 14) {
// UIAlertView *noBarcode =
// [[UIAlertView alloc] initWithTitle:@"Invalid Barcode"
// message:@"Barcode ain't 14 characters"
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
// [noBarcode show];
// } else {
// NSString *stringStart = @"var code = '";
// NSString *stringEnd = @"';";
// NSString *newString = [stringStart stringByAppendingString:barcode];
// NSString *inputCode = [newString stringByAppendingString:stringEnd];
//
// 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];
// Get scanned codes - Testing GetScanned
NSString *getScanPath =
[[NSBundle mainBundle] pathForResource:@"GetScanned" ofType:@"js"];
NSString *getScan =
[NSString stringWithContentsOfFile:getScanPath
encoding:NSUTF8StringEncoding
error:nil];
NSString *scanned =
[self.webview stringByEvaluatingJavaScriptFromString:getScan];
//self.bookLog.text = scanned;
UIAlertView *previousScan =
[[UIAlertView alloc] initWithTitle:@"Previous Scans"
message:scanned
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[previousScan show];
// }
}
}
- (IBAction)continueOnError:(id)sender {
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:@"3"]) { // Error/Action Page
// Continue - Testing GoToScan
NSString *goToScanPath =
[[NSBundle mainBundle] pathForResource:@"GoToScan" ofType:@"js"];
NSString *goToScan = [NSString stringWithContentsOfFile:goToScanPath
encoding:NSUTF8StringEncoding
error:nil];
[self.webview stringByEvaluatingJavaScriptFromString:goToScan];
}
}
- (IBAction)clickedFinish:(id)sender {
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);
// Test FinishScan
if ([page isEqual:@"2"]) { // Scan Page
NSString *finishPath =
[[NSBundle mainBundle] pathForResource:@"FinishScan" ofType:@"js"];
NSString *finish = [NSString stringWithContentsOfFile:finishPath
encoding:NSUTF8StringEncoding
error:nil];
NSString *isFinished =
[self.webview stringByEvaluatingJavaScriptFromString:finish];
if ([isFinished isEqual:@"-1"]) {
} else {
NSLog(@"FINISHED NOT FAILED\n");
}
}
}
- (IBAction)clickedSetup:(id)sender {
NSString *path =
[[NSBundle mainBundle] pathForResource:@"WhatPage" ofType:@"js"];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment