Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andrew D'Abbraccio
PLUC Inventory - Senior Design
Commits
fe9b4f3f
Commit
fe9b4f3f
authored
Mar 18, 2015
by
Alex Moore
Browse files
uploading and pulling - it's been a bit
parent
78de6781
Changes
36
Hide whitespace changes
Inline
Side-by-side
UI-Iteration3/PLUCdraft/AddCollection.js
0 → 100755
View file @
fe9b4f3f
(
function
()
{
var
el
=
document
.
getElementById
(
"
CollectionList1
"
);
var
btn
=
document
.
getElementById
(
"
singleRight
"
);
el
.
selctedIndex
=
selectedAdd
;
// Selected add is the index of selected collection
el
.
value
=
el
.
options
[
selectedAdd
].
value
;
doTransfer1
();
})();
\ No newline at end of file
UI-Iteration3/PLUCdraft/FinishScan.js
0 → 100755
View file @
fe9b4f3f
(
function
()
{
finishedScanning
();
})();
\ No newline at end of file
UI-Iteration3/PLUCdraft/GetAvailableCollections.js
0 → 100755
View file @
fe9b4f3f
(
function
()
{
var
el
=
document
.
getElementById
(
"
CollectionList1
"
);
var
opts
=
el
.
options
;
var
str
=
'
{ "options" : [
'
;
for
(
var
i
=
0
;
i
<
opts
.
length
;
i
++
)
{
str
+=
'
{"value":"
'
+
opts
[
i
].
value
+
'
",
'
+
'
"text":"
'
+
opts
[
i
].
innerHTML
.
trim
()
+
'
"}
'
if
(
i
+
1
!=
opts
.
length
)
str
+=
"
,
"
;
}
str
+=
"
]}
"
;
return
str
;
})();
\ No newline at end of file
UI-Iteration3/PLUCdraft/GetError.js
0 → 100755
View file @
fe9b4f3f
(
function
()
{
var
div
=
document
.
getElementById
(
"
ActionMessage
"
);
var
msg
=
div
.
getElementsByTagName
(
"
td
"
)[
0
].
innerHTML
.
trim
().
replace
(
"
,
"
,
"
-
"
);
return
msg
.
replace
(
/<br>/g
,
"
,
"
);
})();
\ No newline at end of file
UI-Iteration3/PLUCdraft/GetScanned.js
0 → 100755
View file @
fe9b4f3f
(
function
()
{
var
scannedDiv
=
document
.
getElementById
(
"
ScannedListDiv
"
);
var
scannedTB
=
scannedDiv
.
children
[
0
].
children
[
0
];
var
allRows
=
scannedTB
.
children
;
var
scannedRows
=
[];
// Array of tr elements
var
scannedBooks
=
'
{ "books" : [
'
;
// Go through all rows, except header, to get all scanned rows
for
(
var
i
=
1
;
i
<
allRows
.
length
;
i
++
)
{
if
(
allRows
[
i
].
childElementCount
!==
0
)
{
// Ignore empty spacing rows
scannedRows
[
scannedRows
.
length
]
=
allRows
[
i
];
}
}
// Go through scanned rows
for
(
var
j
=
0
;
j
<
scannedRows
.
length
;
j
++
)
{
if
(
scannedRows
[
j
].
children
.
length
!==
0
)
{
// Scanned rows is a tr element with td children
var
rowChildren
=
scannedRows
[
j
].
children
;
// Array of tds
// Go through each td element in a row
for
(
var
k
=
0
;
k
<
rowChildren
.
length
;
k
++
)
{
// k is col num
if
(
rowChildren
[
k
].
childElementCount
!==
0
)
{
// If the td has children (font)
var
bookProp
=
rowChildren
[
k
].
children
[
0
];
// font element
// If the col isn't empty
var
a
=
bookProp
.
innerHTML
;
if
(
bookProp
.
innerHTML
!=
"
"
&&
bookProp
.
innerHTML
!==
""
)
{
switch
(
k
)
{
case
1
:
// ID Prop
scannedBooks
+=
'
{"id":"
'
+
bookProp
.
innerHTML
.
trim
()
+
'
",
'
;
break
;
case
2
:
// Call Num
scannedBooks
+=
'
"callnum":"
'
+
bookProp
.
innerHTML
.
trim
()
+
'
",
'
;
break
;
case
3
:
// Title
scannedBooks
+=
'
"title":"
'
+
bookProp
.
innerHTML
.
trim
()
+
'
"},
'
;
break
;
}
}
}
}
}
}
scannedBooks
=
scannedBooks
.
substring
(
0
,
scannedBooks
.
length
-
1
);
return
scannedBooks
+
'
]}
'
;
})();
\ No newline at end of file
UI-Iteration3/PLUCdraft/GetSelectedCollections.js
0 → 100755
View file @
fe9b4f3f
(
function
()
{
var
el
=
document
.
getElementById
(
"
CollectionList2
"
);
var
opts
=
el
.
options
;
var
str
=
'
{ "options" : [
'
;
for
(
var
i
=
0
;
i
<
opts
.
length
;
i
++
)
{
str
+=
'
{"value":"
'
+
opts
[
i
].
value
+
'
",
'
+
'
"text":"
'
+
opts
[
i
].
innerHTML
.
trim
()
+
'
"}
'
if
(
i
+
1
!=
opts
.
length
)
str
+=
"
,
"
;
}
str
+=
"
]}
"
;
return
str
;
})();
\ No newline at end of file
UI-Iteration3/PLUCdraft/GoToScan.js
0 → 100755
View file @
fe9b4f3f
(
function
()
{
// TODO: Believe this is what the continue button does
onContinue
();
})();
\ No newline at end of file
UI-Iteration3/PLUCdraft/Login.js
0 → 100755
View file @
fe9b4f3f
(
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
"
);
user
.
value
=
"
circ_admin
"
;
pword
.
value
=
"
silver
"
;
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
UI-Iteration3/PLUCdraft/PLUCdraft.xcodeproj/project.pbxproj
View file @
fe9b4f3f
...
...
@@ -26,6 +26,18 @@
EF22332C1A9FA2FC005F0FFC
/* CaptuvoOptionsController.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF22332B1A9FA2FC005F0FFC
/* CaptuvoOptionsController.m */
;
};
EF22332F1A9FA320005F0FFC
/* libCaptuvoSDK.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF22332E1A9FA320005F0FFC
/* libCaptuvoSDK.a */
;
};
EF5D7C151A93E7F7005FD90F
/* SettingsViewController.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF5D7C141A93E7F7005FD90F
/* SettingsViewController.m */
;
};
EF620A211ABA4BFD009E7B46
/* AddCollection.js in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF620A151ABA4BFD009E7B46
/* AddCollection.js */
;
};
EF620A221ABA4BFD009E7B46
/* FinishScan.js in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF620A161ABA4BFD009E7B46
/* FinishScan.js */
;
};
EF620A231ABA4BFD009E7B46
/* GetAvailableCollections.js in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF620A171ABA4BFD009E7B46
/* GetAvailableCollections.js */
;
};
EF620A241ABA4BFD009E7B46
/* GetError.js in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF620A181ABA4BFD009E7B46
/* GetError.js */
;
};
EF620A251ABA4BFD009E7B46
/* GetScanned.js in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF620A191ABA4BFD009E7B46
/* GetScanned.js */
;
};
EF620A261ABA4BFD009E7B46
/* GetSelectedCollections.js in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF620A1A1ABA4BFD009E7B46
/* GetSelectedCollections.js */
;
};
EF620A271ABA4BFD009E7B46
/* GoToScan.js in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF620A1B1ABA4BFD009E7B46
/* GoToScan.js */
;
};
EF620A281ABA4BFD009E7B46
/* Login.js in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF620A1C1ABA4BFD009E7B46
/* Login.js */
;
};
EF620A291ABA4BFD009E7B46
/* RemoveCollection.js in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF620A1D1ABA4BFD009E7B46
/* RemoveCollection.js */
;
};
EF620A2A1ABA4BFD009E7B46
/* SaveSetup.js in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF620A1E1ABA4BFD009E7B46
/* SaveSetup.js */
;
};
EF620A2B1ABA4BFD009E7B46
/* ScanBarcode.js in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EF620A1F1ABA4BFD009E7B46
/* ScanBarcode.js */
;
};
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 */
;
};
EFF4A0F31AB9110800FA82F3
/* WebViewController.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EFF4A0F21AB9110800FA82F3
/* WebViewController.m */
;
};
...
...
@@ -74,6 +86,18 @@
EF22332E1A9FA320005F0FFC
/* libCaptuvoSDK.a */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.ar
;
path
=
libCaptuvoSDK.a
;
sourceTree
=
"<group>"
;
};
EF5D7C131A93E7F7005FD90F
/* SettingsViewController.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
SettingsViewController.h
;
sourceTree
=
"<group>"
;
};
EF5D7C141A93E7F7005FD90F
/* SettingsViewController.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
SettingsViewController.m
;
sourceTree
=
"<group>"
;
};
EF620A151ABA4BFD009E7B46
/* AddCollection.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
AddCollection.js
;
sourceTree
=
"<group>"
;
};
EF620A161ABA4BFD009E7B46
/* FinishScan.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
FinishScan.js
;
sourceTree
=
"<group>"
;
};
EF620A171ABA4BFD009E7B46
/* GetAvailableCollections.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
GetAvailableCollections.js
;
sourceTree
=
"<group>"
;
};
EF620A181ABA4BFD009E7B46
/* GetError.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
GetError.js
;
sourceTree
=
"<group>"
;
};
EF620A191ABA4BFD009E7B46
/* GetScanned.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
GetScanned.js
;
sourceTree
=
"<group>"
;
};
EF620A1A1ABA4BFD009E7B46
/* GetSelectedCollections.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
GetSelectedCollections.js
;
sourceTree
=
"<group>"
;
};
EF620A1B1ABA4BFD009E7B46
/* GoToScan.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
GoToScan.js
;
sourceTree
=
"<group>"
;
};
EF620A1C1ABA4BFD009E7B46
/* Login.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
Login.js
;
sourceTree
=
"<group>"
;
};
EF620A1D1ABA4BFD009E7B46
/* RemoveCollection.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
RemoveCollection.js
;
sourceTree
=
"<group>"
;
};
EF620A1E1ABA4BFD009E7B46
/* SaveSetup.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
SaveSetup.js
;
sourceTree
=
"<group>"
;
};
EF620A1F1ABA4BFD009E7B46
/* ScanBarcode.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
ScanBarcode.js
;
sourceTree
=
"<group>"
;
};
EF620A201ABA4BFD009E7B46
/* WhatPage.js */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.javascript
;
path
=
WhatPage.js
;
sourceTree
=
"<group>"
;
};
EF8005081AB9E1E200A10D56
/* SectionViewController.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
SectionViewController.h
;
sourceTree
=
"<group>"
;
};
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>"
;
};
...
...
@@ -127,6 +151,7 @@
7866F5F01A9D23B4006CEFEB
/* Main.storyboard */
,
EF2233301A9FA327005F0FFC
/* Include */
,
EF2233321A9FA349005F0FFC
/* Source */
,
EF620A141ABA4BBD009E7B46
/* Javascript Resources */
,
EF2233311A9FA32B005F0FFC
/* Libraries */
,
EF2233331A9FA358005F0FFC
/* Resources */
,
78FD6B0B1A81713A00D48A92
/* Supporting Files */
,
...
...
@@ -218,6 +243,26 @@
name
=
Resources
;
sourceTree
=
"<group>"
;
};
EF620A141ABA4BBD009E7B46
/* Javascript Resources */
=
{
isa
=
PBXGroup
;
children
=
(
EF620A151ABA4BFD009E7B46
/* AddCollection.js */
,
EF620A161ABA4BFD009E7B46
/* FinishScan.js */
,
EF620A171ABA4BFD009E7B46
/* GetAvailableCollections.js */
,
EF620A181ABA4BFD009E7B46
/* GetError.js */
,
EF620A191ABA4BFD009E7B46
/* GetScanned.js */
,
EF620A1A1ABA4BFD009E7B46
/* GetSelectedCollections.js */
,
EF620A1B1ABA4BFD009E7B46
/* GoToScan.js */
,
EF620A1C1ABA4BFD009E7B46
/* Login.js */
,
EF620A1D1ABA4BFD009E7B46
/* RemoveCollection.js */
,
EF620A1E1ABA4BFD009E7B46
/* SaveSetup.js */
,
EF620A1F1ABA4BFD009E7B46
/* ScanBarcode.js */
,
EF620A201ABA4BFD009E7B46
/* WhatPage.js */
,
);
name
=
"Javascript Resources"
;
path
=
..
;
sourceTree
=
"<group>"
;
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
...
...
@@ -298,12 +343,24 @@
isa
=
PBXResourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
EF620A251ABA4BFD009E7B46
/* GetScanned.js in Resources */
,
EF620A211ABA4BFD009E7B46
/* AddCollection.js in Resources */
,
EF620A271ABA4BFD009E7B46
/* GoToScan.js in Resources */
,
EF620A221ABA4BFD009E7B46
/* FinishScan.js in Resources */
,
7866F5F11A9D23B4006CEFEB
/* Main.storyboard in Resources */
,
784F46F11A83CF7700EAC872
/* greycheck2.png in Resources */
,
EF620A2C1ABA4BFD009E7B46
/* WhatPage.js in Resources */
,
EF620A281ABA4BFD009E7B46
/* Login.js in Resources */
,
78FD6B381A817F4500D48A92
/* greencheck.png in Resources */
,
EF620A291ABA4BFD009E7B46
/* RemoveCollection.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 */
,
EF620A241ABA4BFD009E7B46
/* GetError.js in Resources */
,
EF620A2B1ABA4BFD009E7B46
/* ScanBarcode.js in Resources */
,
78FD6B191A81713A00D48A92
/* Images.xcassets in Resources */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
...
...
UI-Iteration3/PLUCdraft/PLUCdraft/GlobalWebController.h
View file @
fe9b4f3f
...
...
@@ -13,9 +13,11 @@
@interface
GlobalWebController
:
NSObject
{
UIWebView
*
web
;
bool
isInitialized
;
}
@property
(
nonatomic
,
retain
)
UIWebView
*
web
;
@property
(
nonatomic
,
assign
)
bool
isInitialized
;
+
(
GlobalWebController
*
)
getInstance
;
@end
UI-Iteration3/PLUCdraft/PLUCdraft/GlobalWebController.m
View file @
fe9b4f3f
...
...
@@ -10,6 +10,7 @@
@implementation
GlobalWebController
@synthesize
web
;
@synthesize
isInitialized
;
static
GlobalWebController
*
instance
=
nil
;
...
...
@@ -19,6 +20,7 @@ static GlobalWebController *instance = nil;
{
if
(
instance
==
nil
)
{
instance
=
[
GlobalWebController
new
];
instance
.
isInitialized
=
false
;
}
}
return
instance
;
...
...
UI-Iteration3/PLUCdraft/PLUCdraft/LogInViewController.m
View file @
fe9b4f3f
...
...
@@ -63,13 +63,22 @@ static NSString *PASSWORD = @"";//@"what";
*/
-
(
IBAction
)
btnLogInTouch
:(
id
)
sender
{
if
([
txtUsername
.
text
isEqualToString
:
USERNAME
]
&&
[
txtPassword
.
text
isEqualToString
:
PASSWORD
])
{
//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
];
}
NSString
*
loginPath
=
[[
NSBundle
mainBundle
]
pathForResource
:
@"Login"
ofType
:
@"js"
];
NSString
*
login
=
[
NSString
stringWithContentsOfFile
:
loginPath
encoding:
NSUTF8StringEncoding
error:
nil
];
NSString
*
success
=
[
self
.
webview
stringByEvaluatingJavaScriptFromString
:
login
];
// if([txtUsername.text isEqualToString: USERNAME] && [txtPassword.text isEqualToString:PASSWORD]) {//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
UI-Iteration3/PLUCdraft/PLUCdraft/SectionViewController.m
View file @
fe9b4f3f
...
...
@@ -36,20 +36,20 @@ bool firstLoad = true;
[
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
;
}
//
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;
//
}
}
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
...
...
UI-Iteration3/PLUCdraft/PLUCdraft/WebViewController.h
View file @
fe9b4f3f
...
...
@@ -8,8 +8,9 @@
#import <UIKit/UIKit.h>
@interface
WebViewController
:
UIViewController
@interface
WebViewController
:
UIViewController
<
UIWebViewDelegate
>
@property
(
weak
,
nonatomic
)
IBOutlet
UITextField
*
txtBookID
;
@property
UIWebView
*
webview
;
@end
UI-Iteration3/PLUCdraft/PLUCdraft/WebViewController.m
View file @
fe9b4f3f
...
...
@@ -7,6 +7,7 @@
//
#import "WebViewController.h"
#import "GlobalWebController.h"
@interface
WebViewController
()
...
...
@@ -17,6 +18,25 @@
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
// Do any additional setup after loading the view.
GlobalWebController
*
globalWeb
=
[
GlobalWebController
getInstance
];
if
(
!
globalWeb
.
isInitialized
)
{
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/"]]];
// Test collection page on mac mini desktop
[
self
.
webview
loadRequest
:[
NSURLRequest
requestWithURL
:
[
NSURL
URLWithString:
@"file:///Users/plucseniordesign/Desktop/RTISetup.html"
]]];
[
self
.
webview
setDelegate
:
self
];
}
}
-
(
void
)
viewWillAppear
:(
BOOL
)
animated
{
[
self
.
view
addSubview
:
self
.
webview
];
}
-
(
void
)
didReceiveMemoryWarning
{
...
...
@@ -24,6 +44,331 @@
// Dispose of any resources that can be recreated.
}
-
(
void
)
webViewDidFinishLoad
:(
UIWebView
*
)
webView
{
// Strictly for debugging purposes
[
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
];
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
];
// Continue - Testing GoToScan
NSString
*
goToScanPath
=
[[
NSBundle
mainBundle
]
pathForResource
:
@"GoToScan"
ofType
:
@"js"
];
NSString
*
goToScan
=
[
NSString
stringWithContentsOfFile
:
goToScanPath
encoding:
NSUTF8StringEncoding
error:
nil
];
[
self
.
webview
stringByEvaluatingJavaScriptFromString
:
goToScan
];
UIAlertView
*
errorAlert
=
[[
UIAlertView
alloc
]
initWithTitle
:
@"Error Encountered"
message:
error
delegate:
self
cancelButtonTitle:
@"OK"
otherButtonTitles:
nil
];
[
errorAlert
show
];
}
}
-
(
IBAction
)
loginBtnPressed
:(
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
:
@"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
];
}
}
-
(
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