Commit d022fde9 authored by Jake Mylet's avatar Jake Mylet

Update JS to remove unneccessary empty check, and removed inline comments.

All comments should be in documentation.
parent 450320bc
(function () {
var scannedDiv = document.getElementById("ScannedListDiv");
var scannedTB = scannedDiv.children[0].children[0];
var allRows = scannedTB.children;
var scannedRows = [];
var scannedBooks = '{ "books" : [';
(function () {
var scannedDiv = document.getElementById("ScannedListDiv");
var scannedTB = scannedDiv.children[0].children[0];
var allRows = scannedTB.children;
var scannedRows = [];
var scannedBooks = '{ "books": [';
for (var i = 1; i < allRows.length; i++) {
if (allRows[i].childElementCount !== 0) { // Ignore empty spacing rows
scannedRows[scannedRows.length] = allRows[i];
}
}
for (var i = 1; i < allRows.length; i++) {
if (allRows[i].childElementCount !== 0) {
scannedRows[scannedRows.length] = allRows[i];
}
}
for (var j = 0; j < scannedRows.length; j++) {
var curRow = scannedRows[j].children;
// 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
for (var k = 0; k < curRow.length; k++) {
if (curRow[k].hasAttribute("title")) {
var bookProp = curRow[k].title;
// Go through each td element in a row
for (var k = 0; k < rowChildren.length; k++) { // k is col num
if (rowChildren[k].hasAttribute("title")) {
var bookProp = rowChildren[k].title; // Information desired
switch (k) {
case 1:
scannedBooks += '{"barcode":"' + bookProp.trim() + '", ';
break;
case 2:
scannedBooks += '"callnum":"' + bookProp.trim() + '", ';
break;
case 3:
scannedBooks += '"title":"' + bookProp.trim() + '"},';
break;
}
}
}
}
scannedBooks = scannedBooks.substring(0, scannedBooks.length - 1);
switch (k) {
case 1:
scannedBooks += '{"barcode":"' + bookProp.trim() + '", ';
break;
case 2:
scannedBooks += '"callnum":"' + bookProp.trim() + '", ';
break;
case 3:
scannedBooks += '"title":"' + bookProp.trim() + '"},';
break;
}
}
}
}
}
scannedBooks = scannedBooks.substring(0, scannedBooks.length - 1);
return scannedBooks + ']}';
})();
\ No newline at end of file
return scannedBooks + ']}';
})();
\ No newline at end of file
......@@ -2,6 +2,5 @@
var barcode = document.getElementById("BarcodeInput");
barcode.value = code;
// TODO: Think this is good enough to call function present
recordBarcode();
})();
\ 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