Commit ed775511 authored by Alex Moore's avatar Alex Moore

Merge branch 'master' of gitlab.bucknell.edu:amd026/pluc-inventory-senior-design

parents ab795a3b c47f0edd
## Home
### JavaScript Documentation
See the [JavaScript Index](docs/index.md) for details.
\ No newline at end of file
(function() {
(function () {
var el = document.getElementById("CollectionList1");
var btn = document.getElementById("singleRight");
el.selctedIndex = selectedAdd; // Selected add is the index of selected collection
el.selctedIndex = selectedAdd;
el.value = el.options[selectedAdd].value;
doTransfer1();
})();
\ No newline at end of file
(function() {
(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() + '"}'
str += '{"value":"' + opts[i].value + '", ' + '"text":"' + opts[i].innerHTML.trim() + '"}';
if (i + 1 != opts.length)
str += ",";
......
(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 != "&nbsp;" && bookProp.innerHTML !== "") {
switch(k) {
case 1: // ID Prop - called barcode for later JSON processing (so as not
//to interfere with "id" keyword
scannedBooks += '{"barcode":"' + 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
(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
var tdElement = rowChildren[k];
// Contents of font element
var contents = bookProp.innerHTML;
if (bookProp.innerHTML != "&nbsp;" && contents !== "") {
switch (k) {
case 1:
scannedBooks += '{"barcode":"' + contents.trim() + '", ';
// Look for error bgcolor contained in first td element
if (tdElement.bgColor == "#ffffcc") {
scannedBooks += '"error":"true", ';
}
else {
scannedBooks += '"error":"false", ';
}
break;
case 2: // Call Num
scannedBooks += '"callnum":"' + contents.trim() + '", ';
break;
case 3: // Title
scannedBooks += '"title":"' + contents.trim() + '"},';
break;
}
}
}
}
}
}
scannedBooks = scannedBooks.substring(0, scannedBooks.length - 1);
return scannedBooks + ']}';
})();
\ No newline at end of file
(function() {
(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() + '"}'
str += '{"value":"' + opts[i].value + '", ' + '"text":"' + opts[i].innerHTML.trim() + '"}'
if (i + 1 != opts.length)
str += ",";
......
(function() {
// TODO: Believe this is what the continue button does
onContinue();
})();
\ No newline at end of file
(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 user = document.getElementById("UserID");
var pword = document.getElementById("Password");
var inventory = document.getElementById("InventoryRadioBtn");
var missing = document.getElementById("IDMissingRadioBtn");
//user.value = "circ_admin";
//pword.value = "silver";
user.value = userID;
pword.value = userPassword;
GetLocation();
var loc = document.getElementById("LocationSelCtl"); // Location select
var loc = document.getElementById("LocationSelCtl");
loc.selectedIndex = 2; // Make sure this is the Lewisburg branch
loc.selectedIndex = 2;
loc.value = loc.options[2].value;
inventory.checked = true;
doLogin();
......
(function() {
(function () {
var el = document.getElementById("CollectionList2");
var btn = document.getElementById("singleLeft");
el.selctedIndex = selectedRemove;
el.value = el.options[selectedRemove].value;
doTransfer2();
doTransfer2();
})();
\ No newline at end of file
(function() {
(function () {
var overdue = document.getElementById("IgnoreOverdueFines");
var okBtn = document.getElementById("OkBtn");
overdue.checked = true;
okBtn.click();
OnOk(returnObjById("CollectionList2"), collectionsArray, CheckShelfOrder, IgnoreOverdueFines);
})();
\ No newline at end of file
(function() {
(function () {
var url = document.URL;
if (url.search("Login") != -1)
return 0;
else if (url.search("Setup") != -1)
......
# Error Page JavaScript
The JS functions specified below are run only on the Error Page.
\ No newline at end of file
# Global Scope JavaScript
The JS function specified below is run on every page.
### [WhatPage.js](/WAMI/WAMI/WhatPage.js)
Will determine what page, and therefore the step in the inventory process currently at. This is accomplished by obtaining the URL from the page and search for certain strings in the URL to determine what page the script executes on.
From the URL property of the document object, retrieve the address of the page.
```javascript
var url = document.URL;
```
Use the string search function to determine if there is a certain substring present. This function will return the index of the beginning substring if found or -1 if not present.
```javascript
if (url.search("Login") != -1)
return 0;
else if (url.search("Setup") != -1)
return 1;
else if (url.search("Scan") != -1)
return 2;
else if (url.search("Action") != -1)
return 3;
else
return -1;
```
Function will return 0 through 3 depending upon the step of the inventory process based off of the number of the step in the process or -1 if not on an RTI page.
1. Login Page
2. Setup Page
3. Scan Page
4. Action (i.e. Scan Error) page
---
#### References/See Also
[URL property](http://www.w3schools.com/jsref/prop_doc_url.asp)
[Document object](http://www.w3schools.com/jsref/dom_obj_document.asp)
[String search](http://www.w3schools.com/jsref/jsref_search.asp)
\ No newline at end of file
# Login Page JavaScript
The JS function specified below is run only on the Login Page.
### [Login.js](/WAMI/WAMI/Login.js)
Will get a user name and password from variables, userID and userPassword respectively, injected into the page DOM by the application at an earlier time with values determined by user inupt. It will then set the values of the input fields for user name and password on the page to these input values.
```javascript
var user = document.getElementById("UserID");
var pword = document.getElementById("Password");
user.value = userID;
pword.value = userPassword;
```
After the user name and password are set as the values passed in, the file will call a function declared by the page to determine possible locations mapped to those values, `GetLocation`. It is necessary to have the user name and password set before calling this method. The file then will automatically select the Lewisburg branch as the location, no other location would currently be able to use the new scan system, which is known to be the 3rd option, indexed with 2 rather than 3 as indexing starts with 0. To set the selected location the selected index and value needs to be set to the desired values.
```javascript
GetLocation();
var loc = document.getElementById("LocationSelCtl");
loc.selectedIndex = 2;
loc.value = loc.options[2].value;
```
Then it will automatically proceed to an inventory, by checking the inventory checkbox and calling the internal function to automatically proceed past the login page and start a session, `doLogin`.
```javascript
var inventory = document.getElementById("InventoryRadioBtn");
inventory.checked = true;
doLogin();
```
---
#### References/See Also
[getElementyById Method](http://www.w3schools.com/jsref/met_document_getelementbyid.asp)
[Select Element](http://www.w3schools.com/jsref/dom_obj_select.asp)
[Checkbox Element](http://www.w3schools.com/jsref/dom_obj_checkbox.asp)
# Scan Page JavaScript
The JS functions specified below are run only on the Scan Page.
\ No newline at end of file
# Setup Page JavaScript
The JS functions specified below are run only on the Setup Page.
### [GetAvailableCollections.js](/WAMI/WAMI/GetAvailableCollections.js)
Will get all of the collections available to inventory. First it gets the select element that contains all of the options and creates a variable to temporarily hold these options.
```javascript
var el = document.getElementById("CollectionList1");
var opts = el.options;
```
With these options the function will create a JSON-formatted string with a list of options objects called options being the outer most object. The JSON-formatted option objects themselves contain the value of a collection, which is not the whole text displayed in the select but is a shortened version, and the actual full text of the collection. To create this JSON object the file will iterate through all of the options and use string concatination. After iterating through all options and closing the JSON-string it will return this object back to the application.
```javascript
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;
```
### [GetSelectedCollections.js](/WAMI/WAMI/GetSelectedCollections.js)
Operates in the same way that GetAvailableCollections does, except that it pulls options from the select object containing the collections that have already been selected to inventory.
```javascript
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;
```
### [AddCollection.js](/WAMI/WAMI/AddCollection.js)
Will add a collection from the available list to the list of collections. To do this it will first get the available collection list and then set one of the options within to be the designated "selected element" by setting the selected index and the value. To choose which option is to be selected the application will inject a JavaScript variable, `selectedAdd`, holding the desired index before calling AddCollection. Once an option is selected the file will call a function internal to the web page, `doTransfer1`, that will move the option to the list of collections selected to inventory.
```javascript
var el = document.getElementById("CollectionList1");
el.selctedIndex = selectedAdd;
el.value = el.options[selectedAdd].value;
doTransfer1();
```
### [RemoveCollection.js](/WAMI/WAMI/RemoveCollection.js)
This file works the same way that AddCollection does but gets the select element to remove an option from rather than the available collections select to add an option from. It also has a different variable name to contain the index for the option of interest, `selectedRemove`, and calls a different internal transfer function, `doTransfer2()`.
```javascript
var el = document.getElementById("CollectionList2");
el.selctedIndex = selectedRemove;
el.value = el.options[selectedRemove].value;
doTransfer2();
```
### [SaveSetup.js](/WAMI/WAMI/SaveSetup.js)
Is the last file to be run on the setup page. It will complete the setup process and trigger the advance to the scan page. It does this by getting the element to check if overdue fines are to be ignored, they are for every inventory but can be taken into account by setting the checked property to false rather than true, and checks that fines are to be ignored. It will then call the same internal function that the save setup button calls when it is pressed with the same arguments to save the setup and proceed onto the scan page.
```javascript
var overdue = document.getElementById("IgnoreOverdueFines");
overdue.checked = true;
OnOk(returnObjById("CollectionList2"), collectionsArray, CheckShelfOrder, IgnoreOverdueFines);
```
---
#### References/See Also
[Select Element](http://www.w3schools.com/jsref/dom_obj_select.asp)
[JavaScript Strings](http://www.w3schools.com/jsref/jsref_obj_string.asp)
[Checkbox Element](http://www.w3schools.com/jsref/dom_obj_checkbox.asp)
[JavaScript JSON](http://www.w3schools.com/js/js_json.asp)
# JavaScript Index
This index provides an overview of the different JavaScript functions included in the application. These functions are separated into that are included in this application, which are listed below broken down based upon scope of operation (i.e. page file is utilized on).
## [Global](docs/GlobalJS.md)
* WhatPage.js
File contains function to determine current page, or location in scan process, of the current inventory session.
## [Login Page](docs/LoginJS.md)
* Login.js
Contains function to input login username and password, retrieve and select the correct location information, as well as submit this information and login to RTI.
## [Setup Page](docs/SetupJS.md)
* GetAvailableCollections.js
Contains function to retrieve all collections that are available to be inventoried at the selected location.
* GetSelectedCollections.js
Will retrieve all collections selected to be inventoried in a session.
* AddCollection.js
Will select one of the available collections to be included in an inventory session.
* RemoveCollection.js
Will remove a collection from the list selected to be inventoried.
* SaveSetup.js
Saves the inventory setup, all of the selected collections.
## [Scan Page](docs/ScanJS.md)
* GetScanned.js
Will retrieve previously scanned items present on the scan page.
* ScanBarcode.js
Will insert a barcode into the input field and submit that code.
* FinishScan.js
Calls the internal function of the Scan Page to finish a scan session.
## [Error Page](docs/ErrorJS.md)
* GetError.js
Will retrieve the message triggered by a item scan error.
* GoToScan.js
Advances from the error page to go back to the scan page.
\ No newline at end of file
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