Commit b1b13488 authored by Drewdabb's avatar Drewdabb

first system lib test

parent 690104ba
No preview for this file type
......@@ -122,12 +122,12 @@
// [loginAlert show];
//For testing
if([self.txtUsername.text isEqualToString:@"circ_admin"] && [self.txtPassword.text isEqualToString:@"silver"]) {//check username and password
// 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];
}
// } else {
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Incorrect login" message:@"Username or password incorrect" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
// [alert show];
// }
}
@end
......@@ -19,5 +19,6 @@
@property (weak, nonatomic) IBOutlet UITableView *scannedBookTableView;
//@property (weak, nonatomic) IBOutlet UITextField *txtBookID;
@property (weak, nonatomic) IBOutlet UIButton *finishBtn;
@property (weak, nonatomic) IBOutlet UIWebView *test_view;
@end
......@@ -57,15 +57,20 @@ static int BOOK_ID_LENGTH = 14;
//For testing
[self.webview loadRequest:[NSURLRequest requestWithURL: [NSURL
URLWithString:@"file:///Users/plucseniordesign/Desktop/RTIScan2/RTIScan2.html"]]];
//[self.webview loadRequest:[NSURLRequest requestWithURL: [NSURL
// URLWithString:@"file:///Users/plucseniordesign/Desktop/RTIScan2/RTIScan2.html"]]];
}
-(void) viewDidAppear:(BOOL)animated {
NSLog(@"viewDidAppear, 2nd view controller");
GlobalWebController *globalWeb = [GlobalWebController getInstance];
self.webview = globalWeb.web;
[self.view addSubview:self.webview];
//NSLog(@"viewDidAppear, 2nd view controller");
//GlobalWebController *globalWeb = [GlobalWebController getInstance];
//self.webview = globalWeb.web;
//[self.test_view setDelegate:self];
//self.test_view = globalWeb.web;
//[self.view addSubview:self.webview];
//[self.view addSubview:self.test_view];
//[self.test_view setScalesPageToFit:YES];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
......@@ -73,26 +78,7 @@ static int BOOK_ID_LENGTH = 14;
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];
}
......@@ -102,35 +88,44 @@ static int BOOK_ID_LENGTH = 14;
[self.idList removeAllObjects];
[self.callNumList removeAllObjects];
[self.titleList removeAllObjects];
[self.scannedBookList removeAllObjects];
//Extract book ID
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\"id\"\\:\"([0-9]*)\"" options:0 error: Nil];
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\"id\"\\:\"([0-9]*)\"\\," options:0 error: Nil];
NSArray *rangeList = [regex matchesInString:scannedBooks options:0 range:NSMakeRange(0, [scannedBooks length])];
NSString *idNum;
for(NSTextCheckingResult *range in rangeList) {
[self.idList addObject:[scannedBooks substringWithRange:[range rangeAtIndex:1]]];
idNum = [scannedBooks substringWithRange:[range rangeAtIndex:1]];
NSLog(idNum);
[self.idList addObject:idNum];
}
//Extract book call number
regex = [NSRegularExpression regularExpressionWithPattern:@"\"callnum\"\\:\"([0-9a-zA-Z\\.]*)\"" options:0 error: Nil];
regex = [NSRegularExpression regularExpressionWithPattern:@"\"callnum\"\\:\"([0-9a-zA-Z\\.]*)\"\\," options:0 error: Nil];
rangeList = [regex matchesInString:scannedBooks options:0 range:NSMakeRange(0, [scannedBooks length])];
NSString *callNum;
for(NSTextCheckingResult *range in rangeList) {
[self.callNumList addObject:[scannedBooks substringWithRange:[range rangeAtIndex:1]]];
callNum = [scannedBooks substringWithRange:[range rangeAtIndex:1]];
NSLog(callNum);
[self.callNumList addObject:callNum];
}
//Extract book title
regex = [NSRegularExpression regularExpressionWithPattern:@"\"title\"\\:\"([0-9a-zA-Z\\.\\&\\;]*)\"" options:0 error: Nil];
regex = [NSRegularExpression regularExpressionWithPattern:@"\"title\"\\:\"(.*)\"\\}" 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]];
NSLog(title);
[self.titleList addObject:[scannedBooks substringWithRange:[range rangeAtIndex:1]]];
}
//NSLog(@"%@, %@, %@", [self.idList objectAtIndex:0], [self.callNumList objectAtIndex:0], [self.titleList objectAtIndex:0]);
//Populate table view
NSLog(@"num scanned books = %d", [self.idList count]);
//NSLog(@"num scanned books = %lu", (unsigned long)[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]);
//NSLog(@"%@, %@, %@", [self.idList objectAtIndex:i], [self.callNumList objectAtIndex:i], [self.titleList objectAtIndex:i]);
[self.scannedBookList addObject:[self.idList objectAtIndex:i]];
}
//NSLog(@"Got here");
[self.scannedBookTableView reloadData];
......@@ -233,7 +228,7 @@ static int BOOK_ID_LENGTH = 14;
});
});
}
//31172001492867
- (IBAction)txtChange:(id)sender {
NSCharacterSet* notDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
if(self.txtBookID.text.length == BOOK_ID_LENGTH) { //string is proper length
......@@ -270,7 +265,26 @@ static int BOOK_ID_LENGTH = 14;
self.view.backgroundColor = [UIColor whiteColor];
}];
[self.txtBookID setText:@""];
// 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;
NSLog(@"%@", scanned);
// UIAlertView *previousScan =
// [[UIAlertView alloc] initWithTitle:@"Previous Scans"
// message:scanned
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
//
// [previousScan show];
[self extractInformation:scanned];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid Book ID" message:@"Book ID must be numeric" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
......
......@@ -34,8 +34,7 @@
[self.tableView reloadData];
//For testing
[self.webview loadRequest:[NSURLRequest requestWithURL: [NSURL
URLWithString:@"file:///Users/plucseniordesign/Desktop/RTISetup.html"]]];
//[self.webview loadRequest:[NSURLRequest requestWithURL: [NSURL URLWithString:@"file:///Users/plucseniordesign/Desktop/RTISetup.html"]]];
}
- (void)viewDidAppear:(BOOL)animated {
......@@ -45,6 +44,7 @@
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[super webViewDidFinishLoad:webView];
NSLog(@"got to collections");
// Get collections available - Testing GetAvailableCollections
NSString *getAvailablePath =
......@@ -201,13 +201,22 @@
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];
NSString *saveSetupPath =
[[NSBundle mainBundle] pathForResource:@"SaveSetup" ofType:@"js"];
NSString *saveSetup =
[NSString stringWithContentsOfFile:saveSetupPath
encoding:NSUTF8StringEncoding
error:nil];
[self.webview stringByEvaluatingJavaScriptFromString:saveSetup];
}
......
......@@ -28,14 +28,18 @@
self.webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
globalWeb.web = self.webview;
globalWeb.isInitialized = true;
//[self.webview
// loadRequest:[NSURLRequest
// requestWithURL:
// [NSURL URLWithString:@"http://192.168.1.131/rti/"]]];
NSURLRequest *rti = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://192.168.1.131/rti/"]];
[[NSURLCache sharedURLCache] removeCachedResponseForRequest:rti];
//Clean the cookie jar
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *cookie in [storage cookies]) {
[storage deleteCookie:cookie];
}
[[NSUserDefaults standardUserDefaults] synchronize];
[self.webview loadRequest:rti];
// Test collection page on mac mini desktop
[self.webview loadRequest:[NSURLRequest requestWithURL: [NSURL
URLWithString:@"file:///Users/plucseniordesign/Desktop/response.html"]]];//RTISetup.html"]]];
//[self.webview loadRequest:[NSURLRequest requestWithURL: [NSURL
// URLWithString:@"file:///Users/plucseniordesign/Desktop/response.html"]]];//RTISetup.html"]]];
[self.webview setDelegate:self];
}
else {
......
(function() {
var url = document.URL;
if (url.search("response") != -1)
if (url.search("Login") != -1)
return 0;
else if (url.search("Setup") != -1)
return 1;
......
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