Commit 15bd8d58 authored by Alex Moore's avatar Alex Moore
Browse files

Commit before library test tomorrow

parent b06a2017
...@@ -105,18 +105,6 @@ ...@@ -105,18 +105,6 @@
EF5EF4151A9C09EF00679799 /* headlessbrower_test1 */ = { EF5EF4151A9C09EF00679799 /* headlessbrower_test1 */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
F918F8001AA4DF21009C108D /* WhatPage.js */,
EF8072961AA4D7A700D8FF6C /* FinishScan.js */,
EF8072971AA4D7A700D8FF6C /* GetScanned.js */,
EF8072981AA4D7A700D8FF6C /* ScanBarcode.js */,
EF8072941AA4D79C00D8FF6C /* Login.js */,
EF8072901AA4D78F00D8FF6C /* GetError.js */,
EF8072911AA4D78F00D8FF6C /* GoToScan.js */,
EF8072861AA4CBFF00D8FF6C /* AddCollection.js */,
EF8072871AA4CBFF00D8FF6C /* GetAvailableCollections.js */,
EF8072881AA4CBFF00D8FF6C /* GetSelectedCollections.js */,
EF8072891AA4CBFF00D8FF6C /* RemoveCollection.js */,
EF80728A1AA4CBFF00D8FF6C /* SaveSetup.js */,
EF5EF41A1A9C09EF00679799 /* AppDelegate.h */, EF5EF41A1A9C09EF00679799 /* AppDelegate.h */,
EF5EF41B1A9C09EF00679799 /* AppDelegate.m */, EF5EF41B1A9C09EF00679799 /* AppDelegate.m */,
EF5EF41D1A9C09EF00679799 /* ViewController.h */, EF5EF41D1A9C09EF00679799 /* ViewController.h */,
...@@ -132,6 +120,18 @@ ...@@ -132,6 +120,18 @@
EF5EF4161A9C09EF00679799 /* Supporting Files */ = { EF5EF4161A9C09EF00679799 /* Supporting Files */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
EF8072961AA4D7A700D8FF6C /* FinishScan.js */,
EF8072971AA4D7A700D8FF6C /* GetScanned.js */,
EF8072981AA4D7A700D8FF6C /* ScanBarcode.js */,
EF8072941AA4D79C00D8FF6C /* Login.js */,
EF8072901AA4D78F00D8FF6C /* GetError.js */,
EF8072911AA4D78F00D8FF6C /* GoToScan.js */,
EF8072861AA4CBFF00D8FF6C /* AddCollection.js */,
EF8072871AA4CBFF00D8FF6C /* GetAvailableCollections.js */,
EF8072881AA4CBFF00D8FF6C /* GetSelectedCollections.js */,
EF8072891AA4CBFF00D8FF6C /* RemoveCollection.js */,
EF80728A1AA4CBFF00D8FF6C /* SaveSetup.js */,
F918F8001AA4DF21009C108D /* WhatPage.js */,
EF5EF4171A9C09EF00679799 /* Info.plist */, EF5EF4171A9C09EF00679799 /* Info.plist */,
EF5EF4181A9C09EF00679799 /* main.m */, EF5EF4181A9C09EF00679799 /* main.m */,
); );
......
(function() { (function() {
var el = document.getElementById("CollectionList1"); var el = document.getElementById("CollectionList1");
var btn = document.getElementById("singleRight"); var btn = document.getElementById("singleRight");
el.selctedIndex = selectedAdd; el.selctedIndex = selectedAdd; // Selected add is the index of selected collection
el.value = el.options[selectedAdd];
doTransfer1(); doTransfer1();
})(); })();
\ No newline at end of file
...@@ -18,21 +18,118 @@ ...@@ -18,21 +18,118 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PJD-sX-uSn"> <webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PJD-sX-uSn">
<rect key="frame" x="139" y="2" width="322" height="595"/> <rect key="frame" x="0.0" y="2" width="322" height="595"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</webView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zoO-ob-cYc">
<rect key="frame" x="378" y="28" width="46" height="30"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="322" id="UkT-51-5Bj"/> <constraint firstAttribute="height" constant="30" id="b6z-M3-xDO"/>
<constraint firstAttribute="width" constant="46" id="zOn-I6-tLG"/>
</constraints> </constraints>
</webView> <state key="normal" title="Log In">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="loginBtnPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="k82-5H-WoN"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="B57-x3-gQW">
<rect key="frame" x="441" y="113" width="46" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="46" id="2T5-K9-rG6"/>
<constraint firstAttribute="height" constant="30" id="OfQ-bS-VvD"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue-Bold" family="Helvetica Neue" pointSize="15"/>
<state key="normal" title="Scan"/>
<connections>
<action selector="scanBtnPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Axa-LX-Tfs"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EGt-8r-Xtn">
<rect key="frame" x="386" y="151" width="163" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="8NL-ta-0pK"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue-Bold" family="Helvetica Neue" pointSize="15"/>
<state key="normal" title="Continue (Error)"/>
<connections>
<action selector="continueOnError:" destination="BYZ-38-t0r" eventType="touchUpInside" id="wug-uh-PP9"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Z3-XO-gQm">
<rect key="frame" x="441" y="189" width="46" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="qdU-6y-7L7"/>
</constraints>
<fontDescription key="fontDescription" name="HelveticaNeue-Bold" family="Helvetica Neue" pointSize="15"/>
<state key="normal" title="Finish"/>
<connections>
<action selector="clickedFinish:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Jsh-5u-b9Y"/>
</connections>
</button>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Enter barcode here" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="PlL-3i-pum">
<rect key="frame" x="378" y="66" width="178" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="7sn-wt-pgi"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="book log" lineBreakMode="tailTruncation" numberOfLines="30" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kwP-90-kst">
<rect key="frame" x="342" y="232" width="242" height="348"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F8k-Rl-Aw8">
<rect key="frame" x="510" y="28" width="46" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="46" id="ixp-n9-1Pl"/>
</constraints>
<state key="normal" title="Setup">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="clickedSetup:" destination="BYZ-38-t0r" eventType="touchUpInside" id="RxC-T4-1Pc"/>
</connections>
</button>
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints> <constraints>
<constraint firstItem="PJD-sX-uSn" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="2Oe-QQ-8Ko"/> <constraint firstItem="kwP-90-kst" firstAttribute="top" secondItem="0Z3-XO-gQm" secondAttribute="bottom" constant="13" id="23k-fM-fi5"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="PJD-sX-uSn" secondAttribute="bottom" constant="3" id="B70-9K-Lc4"/> <constraint firstItem="F8k-Rl-Aw8" firstAttribute="leading" secondItem="zoO-ob-cYc" secondAttribute="trailing" constant="86" id="42t-Ne-vJ3"/>
<constraint firstItem="PJD-sX-uSn" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="topMargin" constant="2" id="hrC-0D-WZz"/> <constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="PJD-sX-uSn" secondAttribute="bottom" constant="3" id="8dI-85-ayG"/>
<constraint firstItem="PJD-sX-uSn" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="topMargin" constant="2" id="DhB-8q-Qkt"/>
<constraint firstItem="kwP-90-kst" firstAttribute="trailing" secondItem="8bC-Xf-vdC" secondAttribute="trailingMargin" id="DwR-n0-HyA"/>
<constraint firstItem="0Z3-XO-gQm" firstAttribute="leading" secondItem="B57-x3-gQW" secondAttribute="leading" id="Jki-9g-5vC"/>
<constraint firstItem="PJD-sX-uSn" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="JnW-vV-g6V"/>
<constraint firstItem="0Z3-XO-gQm" firstAttribute="top" secondItem="EGt-8r-Xtn" secondAttribute="bottom" constant="8" symbolic="YES" id="XmG-R6-2P0"/>
<constraint firstAttribute="trailingMargin" secondItem="B57-x3-gQW" secondAttribute="trailing" constant="97" id="b78-gf-8Fd"/>
<constraint firstItem="PlL-3i-pum" firstAttribute="trailing" secondItem="F8k-Rl-Aw8" secondAttribute="trailing" id="bu9-u3-IgK"/>
<constraint firstItem="0Z3-XO-gQm" firstAttribute="trailing" secondItem="B57-x3-gQW" secondAttribute="trailing" id="c8G-Ny-cXk"/>
<constraint firstItem="EGt-8r-Xtn" firstAttribute="top" secondItem="B57-x3-gQW" secondAttribute="bottom" constant="8" symbolic="YES" id="ca4-Zg-Pbo"/>
<constraint firstItem="zoO-ob-cYc" firstAttribute="leading" secondItem="PlL-3i-pum" secondAttribute="leading" id="hWv-zs-Haf"/>
<constraint firstItem="B57-x3-gQW" firstAttribute="top" secondItem="PlL-3i-pum" secondAttribute="bottom" constant="17" id="hbF-IS-6L5"/>
<constraint firstItem="EGt-8r-Xtn" firstAttribute="centerX" secondItem="PlL-3i-pum" secondAttribute="centerX" id="oyd-q1-nyo"/>
<constraint firstItem="EGt-8r-Xtn" firstAttribute="leading" secondItem="PJD-sX-uSn" secondAttribute="trailing" constant="64" id="rob-46-EA2"/>
<constraint firstItem="PlL-3i-pum" firstAttribute="top" secondItem="zoO-ob-cYc" secondAttribute="bottom" constant="8" symbolic="YES" id="sAX-Uc-bCC"/>
<constraint firstAttribute="bottom" secondItem="kwP-90-kst" secondAttribute="bottom" constant="20" symbolic="YES" id="t9N-dO-4O3"/>
<constraint firstItem="kwP-90-kst" firstAttribute="leading" secondItem="PJD-sX-uSn" secondAttribute="trailing" constant="20" id="tB6-td-ojF"/>
<constraint firstItem="zoO-ob-cYc" firstAttribute="baseline" secondItem="F8k-Rl-Aw8" secondAttribute="baseline" id="voa-k1-dS2"/>
<constraint firstAttribute="trailingMargin" secondItem="F8k-Rl-Aw8" secondAttribute="trailing" constant="28" id="vtK-4g-ILt"/>
<constraint firstItem="zoO-ob-cYc" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="8" symbolic="YES" id="xMH-wL-Kf3"/>
<constraint firstItem="zoO-ob-cYc" firstAttribute="leading" secondItem="PJD-sX-uSn" secondAttribute="trailing" constant="56" id="yEq-aq-y2a"/>
</constraints> </constraints>
</view> </view>
<connections> <connections>
<outlet property="barcodeField" destination="PlL-3i-pum" id="Bkq-sM-Vqs"/>
<outlet property="bookLog" destination="kwP-90-kst" id="irG-D8-ger"/>
<outlet property="btnLogin" destination="zoO-ob-cYc" id="hGJ-lB-AjQ"/>
<outlet property="continueBtn" destination="EGt-8r-Xtn" id="pEF-ld-2cj"/>
<outlet property="finishButton" destination="0Z3-XO-gQm" id="fhN-F1-Q5d"/>
<outlet property="scanButton" destination="B57-x3-gQW" id="UQe-tp-kEB"/>
<outlet property="setupButton" destination="F8k-Rl-Aw8" id="Da7-ux-e0k"/>
<outlet property="test_view" destination="PJD-sX-uSn" id="G6l-DL-LPN"/> <outlet property="test_view" destination="PJD-sX-uSn" id="G6l-DL-LPN"/>
</connections> </connections>
</viewController> </viewController>
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
user.value = "circ_admin"; user.value = "circ_admin";
pword.value = "silver"; pword.value = "silver";
getLocation();
loc.selectedIndex = 1; // Make sure this is the Lewisburg branch loc.selectedIndex = 1; // Make sure this is the Lewisburg branch
inventory.checked = true; inventory.checked = true;
......
...@@ -11,6 +11,13 @@ ...@@ -11,6 +11,13 @@
@interface ViewController : UIViewController<UIWebViewDelegate> @interface ViewController : UIViewController<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *test_view; @property (weak, nonatomic) IBOutlet UIWebView *test_view;
@property (weak, nonatomic) IBOutlet UIButton *btnLogin;
@property (weak, nonatomic) IBOutlet UITextField *barcodeField;
@property (weak, nonatomic) IBOutlet UIButton *scanButton;
@property (weak, nonatomic) IBOutlet UIButton *continueBtn;
@property (weak, nonatomic) IBOutlet UIButton *finishButton;
@property (weak, nonatomic) IBOutlet UIButton *setupButton;
@property (weak, nonatomic) IBOutlet UILabel*bookLog;
@end @end
...@@ -14,178 +14,214 @@ ...@@ -14,178 +14,214 @@
@implementation ViewController @implementation ViewController
bool webview_loaded;
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. //[self.test_view loadRequest:[NSURLRequest requestWithURL:
// [self.test_view loadRequest:[NSURLRequest requestWithURL:[NSURL // [NSURL URLWithString:@"http://192.168.1.131/rti/"]]];
// URLWithString:@"http://www.xkcd.com"]]];
[self.test_view // Test collection page on mac mini desktop
loadRequest:[NSURLRequest [self.test_view loadRequest:[NSURLRequest requestWithURL: [NSURL URLWithString:@"file:///Users/plucseniordesign/Desktop/RTISetup.html"]]];
requestWithURL:
[NSURL URLWithString:@"http://192.168.1.131/rti/"]]]; [self.test_view setDelegate:self];
// NSMutableURLRequest *rq = [NSMutableURLRequest requestWithURL:[NSURL
// URLWithString:@"http://www.google.com"]];
//[rq setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2)
// AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18"
// forHTTPHeaderField:@"User-Agent"];
//[self.test_view loadRequest:rq];
[self.test_view setDelegate:self];
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. // Dispose of any resources that can be recreated.
} }
- (void)webViewDidFinishLoad:(UIWebView *)webView { - (void)webViewDidFinishLoad:(UIWebView *)webView {
[webView stringByEvaluatingJavaScriptFromString:@"var test1 = 'Hello Pluto'"]; // Strictly for debugging purposes
NSString *newHtml = [webView stringByEvaluatingJavaScriptFromString:@"test1"]; [webView stringByEvaluatingJavaScriptFromString:@"var test1 = 'Hello Pluto'"];
NSLog(@"%@\n", newHtml); NSString *newHtml = [webView stringByEvaluatingJavaScriptFromString:@"test1"];
NSLog(@"%@\n", newHtml);
NSString *path =
[[NSBundle mainBundle] pathForResource:@"WhatPage" ofType:@"js"]; NSString *path =
NSString *content = [NSString stringWithContentsOfFile:path [[NSBundle mainBundle] pathForResource:@"WhatPage" ofType:@"js"];
encoding:NSUTF8StringEncoding NSString *content = [NSString stringWithContentsOfFile:path
error:nil]; encoding:NSUTF8StringEncoding
error:nil];
NSString *page = [webView stringByEvaluatingJavaScriptFromString:content];
NSLog(@"PAGE NUMBER IS: %@\n", page); 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];
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];
UIAlertView *selectedAlert = [[UIAlertView alloc] initWithTitle:@"Collections Selected" message:selected 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];
} else if ([page isEqual:@"3"]) { // Error/Action Page
// Get the error - Testing GetError
NSString *getErrorPath = [[NSBundle mainBundle] pathForResource:@"GetError" ofType:@"js"];
NSString *getError = [NSString stringWithContentsOfFile:getErrorPath encoding:NSUTF8StringEncoding error:nil];
NSString *error = [webView stringByEvaluatingJavaScriptFromString:getError];
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error Encountered" message:error delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
}
if ([page isEqual:@"0"]) { // Login Page - (IBAction)loginBtnPressed:(id)sender {
NSString *loginPath = NSString *path =
[[NSBundle mainBundle] pathForResource:@"WhatPage" ofType:@"js"];
NSString *content = [NSString stringWithContentsOfFile:path
encoding:NSUTF8StringEncoding
error:nil];
NSString *page = [self.test_view stringByEvaluatingJavaScriptFromString:content];
NSLog(@"PAGE NUMBER IS: %@\n", page);
if ([page isEqual:@"0"]) { // Login Page
NSString *loginPath =
[[NSBundle mainBundle] pathForResource:@"Login" ofType:@"js"]; [[NSBundle mainBundle] pathForResource:@"Login" ofType:@"js"];
NSString *login = [NSString stringWithContentsOfFile:loginPath NSString *login = [NSString stringWithContentsOfFile:loginPath
encoding:NSUTF8StringEncoding encoding:NSUTF8StringEncoding
error:nil]; error:nil];
NSString *success = [webView stringByEvaluatingJavaScriptFromString:login]; NSString *success = [self.test_view stringByEvaluatingJavaScriptFromString:login];
} else if ([page isEqual:@"1"]) { // Setup Page
// Get collections available - Testing GetAvailableCollections UIAlertView *loginAlert = [[UIAlertView alloc] initWithTitle:@"Logged In!" message:success delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
// NSString *getAvailablePath = [loginAlert show];
// [[NSBundle mainBundle] pathForResource:@"GetAvailableCollections"
// ofType:@"js"];
// NSString *getAvailable =
// [NSString stringWithContentsOfFile:getAvailablePath
// encoding:NSUTF8StringEncoding
// error:nil];
// NSString *available =
// [webView stringByEvaluatingJavaScriptFromString:getAvailable];
// NSLog(@"%@\n", available);
// Add two collections - Testing AddCollection
NSString *addSelectedPath =
[[NSBundle mainBundle] pathForResource:@"AddCollection" ofType:@"js"];
NSString *addSelected =
[NSString stringWithContentsOfFile:addSelectedPath
encoding:NSUTF8StringEncoding
error:nil];
NSString *selected = [webView
stringByEvaluatingJavaScriptFromString:@"var selectedAdd = 1;"];
NSString *add =
[webView stringByEvaluatingJavaScriptFromString:addSelected];
if ([add isEqual:@"-1"]) {
NSLog(@"FAILED\n");
} else {
NSLog(@"NOT FAILED\n");
} }
}
selected = [webView - (IBAction)scanBtnPressed:(id)sender {
stringByEvaluatingJavaScriptFromString:@"var selectedAdd = 2;"]; NSString *path =
add = [webView stringByEvaluatingJavaScriptFromString:addSelected]; [[NSBundle mainBundle] pathForResource:@"WhatPage" ofType:@"js"];
NSString *content = [NSString stringWithContentsOfFile:path
// Get all of the collections selected - Testing GetSelectedCollections
// NSString *getSelectedPath = [[NSBundle mainBundle]
// pathForResource:@"GetSelectedCollections" ofType:@"js"];
// NSString *getSelected = [NSString
// stringWithContentsOfFile:getSelectedPath encoding:NSUTF8StringEncoding
// error:nil];
// NSString *currentSelected = [webView
// stringByEvaluatingJavaScriptFromString:getSelected];
// NSLog(@"%@\n", currentSelected);
// Remove one collection selected - Testing RemoveCollection
// NSString *removeSelectedPath = [[NSBundle mainBundle]
// pathForResource:@"RemoveCollection" ofType:@"js"];
// NSString *removeSelected = [NSString
// stringWithContentsOfFile:removeSelectedPath encoding:NSUTF8StringEncoding
// error:nil];
// NSString *selectedRemove = [webView
// stringByEvaluatingJavaScriptFromString:@"var selectedRemove = 1;"];
// NSString *remove = [webView
// stringByEvaluatingJavaScriptFromString:removeSelected];
// Save setup configuration - Testing SaveSetup
// NSString *saveSetupPath = [[NSBundle mainBundle]
// pathForResource:@"SaveSetup" ofType:@"js"];
// NSString *saveSetup = [NSString stringWithContentsOfFile:saveSetupPath
// encoding:NSUTF8StringEncoding error:nil];
// NSString *save = [webView
// stringByEvaluatingJavaScriptFromString:saveSetup];
} else if ([page isEqual:@"2"]) { // Scan Page
// Scan in an input (arbitrary string of "1234567") - Testing ScanBarcode
// NSString *scanPath =
// [[NSBundle mainBundle] pathForResource:@"ScanBarcode" ofType:@"js"];
// NSString *scan = [NSString stringWithContentsOfFile:scanPath
// encoding:NSUTF8StringEncoding
// error:nil];
// NSString *code = [webView
// stringByEvaluatingJavaScriptFromString:@"var code = '1234567';"];
// NSString *scaned = [webView stringByEvaluatingJavaScriptFromString:scan];
// Get scanned codes - Testing GetScanned
NSString *getScanPath =
[[NSBundle mainBundle] pathForResource:@"GetScanned" ofType:@"js"];
NSString *getScan = [NSString stringWithContentsOfFile:getScanPath
encoding:NSUTF8StringEncoding encoding:NSUTF8StringEncoding
error:nil]; error:nil];
NSString *page = [self.test_view stringByEvaluatingJavaScriptFromString:content];
NSLog(@"PAGE NUMBER IS: %@\n", page);
if ([page isEqual:@"2"]) { // Scan Page
// Get scanned codes - Testing GetScanned
NSString *barcode = self.barcodeField.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.test_view stringByEvaluatingJavaScriptFromString:inputCode];
[self.test_view stringByEvaluatingJavaScriptFromString:scan];
}
}
}
- (IBAction)continueOnError:(id)sender {
NSString *path =
[[NSBundle mainBundle] pathForResource:@"WhatPage" ofType:@"js"];
NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSString *page = [self.test_view 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.test_view stringByEvaluatingJavaScriptFromString:goToScan];
}
}
NSString *scanned = - (IBAction)clickedFinish:(id)sender {
[webView stringByEvaluatingJavaScriptFromString:getScan]; NSString *path =
NSLog(@"Scanned codes: %@\n", scanned); [[NSBundle mainBundle] pathForResource:@"WhatPage" ofType:@"js"];
NSString *content = [NSString stringWithContentsOfFile:path
encoding:NSUTF8StringEncoding
error:nil];
NSString *page = [self.test_view stringByEvaluatingJavaScriptFromString:content];
NSLog(@"PAGE NUMBER IS: %@\n", page);
// Test FinishScan // Test FinishScan
// NSString *finishPath = if ([page isEqual:@"2"]) { // Scan Page
// [[NSBundle mainBundle] pathForResource:@"FinishScan" ofType:@"js"]; NSString *finishPath =
// NSString *finish = [NSString stringWithContentsOfFile:finishPath [[NSBundle mainBundle] pathForResource:@"FinishScan" ofType:@"js"];
// encoding:NSUTF8StringEncoding NSString *finish = [NSString stringWithContentsOfFile:finishPath
// error:nil]; encoding:NSUTF8StringEncoding
error:nil];
// NSString *isFinished =
// [webView stringByEvaluatingJavaScriptFromString:finish]; NSString *isFinished =
// if ([isFinished isEqual:@"-1"]) { [self.test_view stringByEvaluatingJavaScriptFromString:finish];
//} else { if ([isFinished isEqual:@"-1"]) {
// NSLog(@"FINISHED NOT FAILED\n"); } else {
//} NSLog(@"FINISHED NOT FAILED\n");
}
} else if ([page isEqual:@"3"]) { // Error/Action Page }
// Get the error - Testing GetError }
NSString *getErrorPath =
[[NSBundle mainBundle] pathForResource:@"GetError" ofType:@"js"]; - (IBAction)clickedSetup:(id)sender {
NSString *getError = [NSString stringWithContentsOfFile:getErrorPath NSString *path =
encoding:NSUTF8StringEncoding [[NSBundle mainBundle] pathForResource:@"WhatPage" ofType:@"js"];
error:nil]; NSString *content = [NSString stringWithContentsOfFile:path
encoding:NSUTF8StringEncoding
NSString *error = [webView stringByEvaluatingJavaScriptFromString:getError]; error:nil];