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

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
......@@ -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");
//GlobalWebController *globalWeb = [GlobalWebController getInstance];
//self.webview = globalWeb.web;
[self.view addSubview:self.webview];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[super webViewDidFinishLoad:webView];
NSLog(@"webViewDidFinishLoad");
[self getCollections];
[self.tableView reloadData];
}
-(void)loadData:(NSMutableArray *) sectionList {
for(NSString *section in sectionList ) {
[self.sections addObject:section];
}
}
-(void)getCollections {
// Get collections available - Testing GetAvailableCollections
NSString *getAvailablePath =
[[NSBundle mainBundle] pathForResource:@"GetAvailableCollections"
......@@ -86,13 +57,13 @@ bool firstLoad = true;
NSString *available =
[self.webview stringByEvaluatingJavaScriptFromString:getAvailable];
// UIAlertView *collectionAlert =
// [[UIAlertView alloc] initWithTitle:@"Collections Available"
// message:available
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
// [collectionAlert show];
// UIAlertView *collectionAlert =
// [[UIAlertView alloc] initWithTitle:@"Collections Available"
// message:available
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
// [collectionAlert show];
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\"text\":\"([a-zA-Z\\s]*)\"" options:0 error: Nil];
NSArray *rangeList = [regex matchesInString:available options:0 range:NSMakeRange(0, [available length])];
......@@ -100,9 +71,11 @@ bool firstLoad = true;
for(NSTextCheckingResult *range in rangeList) {
[sectionList addObject:[available substringWithRange:[range rangeAtIndex:1]]];
}
//NSLog(@"%@", sectionList);
[self loadData:sectionList];
for(NSString *section in sectionList ) {
[self.sections addObject:section];
}
[self.tableView reloadData];
}
- (void)didReceiveMemoryWarning {
......@@ -197,6 +170,44 @@ bool firstLoad = true;
destViewController.session = session;
//need to call AddCollection, then GetSelectedCollections
//AddCollection
NSString *addSelectedPath =
[[NSBundle mainBundle] pathForResource:@"AddCollection"
ofType:@"js"];
NSString *addSelected =
[NSString stringWithContentsOfFile:addSelectedPath
encoding:NSUTF8StringEncoding
error:nil];
[self.webview
stringByEvaluatingJavaScriptFromString:@"var selectedAdd = 49;"];
NSString *add =
[self.webview
stringByEvaluatingJavaScriptFromString:addSelected];
if ([add isEqual:nil]) {
NSLog(@"nil failed");
} else {
NSLog(@"NOT NILL UNFAILED");
}
//GetSelectedCollections
NSString *selectedPath =
[[NSBundle mainBundle] pathForResource:@"GetSelectedCollections"
ofType:@"js"];
NSString *selectedFunc =
[NSString stringWithContentsOfFile:selectedPath
encoding:NSUTF8StringEncoding
error:nil];
NSString *selected =
[self.webview stringByEvaluatingJavaScriptFromString:selectedFunc];
UIAlertView *selectedAlert =
[[UIAlertView alloc] initWithTitle:@"Collections Selected"
message:selected
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[selectedAlert show];
}
......
......@@ -11,6 +11,8 @@
@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
......@@ -14,6 +14,8 @@
@end
@implementation WebViewController
//@synthesize txtUsername;
//@synthesize txtPassword;
- (void)viewDidLoad {
[super viewDidLoad];
......@@ -30,7 +32,12 @@
// Test collection page on mac mini desktop
[self.webview loadRequest:[NSURLRequest requestWithURL: [NSURL
URLWithString:@"file:///Users/plucseniordesign/Desktop/RTISetup.html"]]];
URLWithString:@"file:///Users/plucseniordesign/Desktop/response.html"]]];//RTISetup.html"]]];
[self.webview setDelegate:self];
}
else {
self.webview = [GlobalWebController getInstance].web;
[self.view addSubview:self.webview];
[self.webview setDelegate:self];
}
}
......@@ -59,67 +66,35 @@
NSString *page = [webView stringByEvaluatingJavaScriptFromString:content];
NSLog(@"PAGE NUMBER IS: %@\n", page);
// if ([page isEqual:@"1"]) { // Setup Page
// // Get collections available - Testing GetAvailableCollections
// NSString *getAvailablePath =
// [[NSBundle mainBundle] pathForResource:@"GetAvailableCollections"
// ofType:@"js"];
// NSString *getAvailable =
// [NSString stringWithContentsOfFile:getAvailablePath
// encoding:NSUTF8StringEncoding
// error:nil];
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 *available =
// [webView stringByEvaluatingJavaScriptFromString:getAvailable];
// UIAlertView *collectionAlert =
// [[UIAlertView alloc] initWithTitle:@"Collections Available"
// message:available
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
// [collectionAlert show];
//
// // Get selected collections
// NSString *selectedPath =
// [[NSBundle mainBundle] pathForResource:@"GetSelectedCollections"
// ofType:@"js"];
// NSString *selectedFunc =
// [NSString stringWithContentsOfFile:selectedPath
// encoding:NSUTF8StringEncoding
// error:nil];
// NSString *selected =
// [webView stringByEvaluatingJavaScriptFromString:selectedFunc];
// NSString *scanned =
// [webView stringByEvaluatingJavaScriptFromString:getScan];
// //self.bookLog.text = scanned;
//
// UIAlertView *selectedAlert =
// [[UIAlertView alloc] initWithTitle:@"Collections Selected"
// message:selected
// UIAlertView *previousScan =
// [[UIAlertView alloc] initWithTitle:@"Previous Scans"
// message:scanned
// delegate:self
// cancelButtonTitle:@"OK"
// otherButtonTitles:nil];
// [selectedAlert show];
//
// } else
if ([page isEqual:@"2"]) { // Scan Page
// 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];
// [previousScan show];