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

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
......@@ -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