Commit 450320bc authored by Jake Mylet's avatar Jake Mylet

Update ScanJS markdown doc to include pertinent information of JS functions in this scope.

parent 48044e9d
......@@ -8,21 +8,81 @@ GetSanned.js will only return scanned items contained in the table on the page,
```javascript
for (var i = 1; i < allRows.length; i++) {
// Row is spacing if it doesn't have any children (i.e. columns, etc.)
if (allRows[i].childElementCount !== 0) {
scannedRows[scannedRows.length] = allRows[i];
scannedRows[scannedRows.length] = allRows[i]; // Store all non-spacing rows
}
}
```
Header rows are ignored by starting at the 2nd row, index 1, rather than the first, index 0. Empy rows are ignored by checking if the row has any child elements.
Header rows are ignored by starting at the 2nd row, index 1, rather than the first, index 0. Empty rows are ignored by checking if the row has any child elements.
After retrieving all scan rows, the script will iterate through each of these rows and then go through every column in a row looking for the information desired. If the information is encountered put it into the JSON formatted list of books declared earlier in the function in a format as specified below.
```javascript
// Scanned Records JSON format
{ "books":
[
{
"barcode": "barcodeValue",
"callnum": "callnumValue",
"title": "titleValue"
},
{...},...
]
}
```
**Note that whitespace is irrelevant**
```javascript
// From scanned rows stored apart from all rows, all rows containing records
for (var j = 0; j < scannedRows.length; j++) {
var curRow = scannedRows[j].children; // Array of tds (columns)
// Go through each column in the row
for (var k = 0; k < rowChildren.length; k++) {
if (rowChildren[k].hasAttribute("title")) { // Info desired is held in colum title attribute
var bookProp = rowChildren[k].title;
// Determine what the information is and add it to the scanned books JSON list
switch (k) {
case 1: // Start at second column as numbering starts at 0 and the first is spacing
scannedBooks += '{"barcode":"' + bookProp.trim() + '", ';
break;
case 2:
scannedBooks += '"callnum":"' + bookProp.trim() + '", ';
break;
case 3:
scannedBooks += '"title":"' + bookProp.trim() + '"},';
break;
}
}
}
}
```
**Note that changes to the scanned list table can cause unpredictable behavior.**
The function is dependent on encountering information in an expected order of barcode number, callnumber, and title while iterating through the columns of a row, with any scan error information stored in the callnumber. If this order changes the script will incorrectly identify certain properties or not save others if they are pushed out of it's range.
Once all rows have been scoured for scanned records, remove the last comma and return the JSON string capped with a bracket and a brace to end the JSON string.
After retrieving all scan rows, the script will iterate through each of these rows and then go through each column in a row looking for the information desired.
```javascript
scannedBooks = scannedBooks.substring(0, scannedBooks.length - 1); // Trim last comma
return scannedBooks + ']}'; // Cap end of string and return
```
### [ScanBarcode.js](/WAMI/WAMI/ScanBarcode.js)
Scan barcode is a very short function that is designed to, as the name suggests, simulate the scanning of a barcode. Before the function can be called it needs a JavaScript variable, `code`, to be declared and its value to be set to that of the item which was scanned. Once this is complete and the function is executed it will get the barcode input field of the page, `BarcodeInput`, and set that value to the barcode stored in the variable code. The function will then call the page's internal function to save that code, `recordCode`, at which point the function has completed its procedure.
```javascript
var barcode = document.getElementById("BarcodeInput");
barcode.value = code;
recordBarcode();
```
### [FinishScan.js](/WAMI/WAMI/FinishScan.js)
\ No newline at end of file
### [FinishScan.js](/WAMI/WAMI/FinishScan.js)
This function is not currently used by the WAMI application as the Library Staff felt it would be advantageous to remove the change of clicking Finish before completing a scan, requiring another inventory of those sections to correctly mark books as missing or not. Finish scan is designed to finish an inventory scan, by emulating the Finish button on the RTI scan page. This ends up being very simple one line procedure to call the internal function that finishes a scan, `finishedScanning`, that the finish button on the page calls. This behavior can be added by following the pattern set forth by the other application buttons which call JavaScript functions.
\ 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