Created
March 14, 2018 20:54
-
-
Save M0N57R0517Y/ed1fd410994236a199e30def28aa1413 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Generated from Java with JSweet 2.0.0 - http://www.jsweet.org */ | |
/*jshint sub:true*/ | |
function Main(InputString){ | |
Main.main = function () { | |
//Variables: | |
// [Shelf #, First Call No, Last Call No, First Call No Comp, Last Call No Comp.] | |
// Note: Shelf arrays[0] is a blank. | |
// Make sure that the first Shelf # is 1, not 0. Leave Shelf # = 0 blank. | |
//var ShelfNumber = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]; | |
var FirstCallNo = [10000, 10000, 10000, 700.0, 800.0, 900.0, 10000, 0.001, 300.0, 400.0, 500.0, 600.0, 10000, 10000]; | |
var LastCallNo = [10000, 10000, 10000, 799.999, 899.999, 999.999, 10000, 299.999, 399.999, 499.999, 599.999, 699.999, 10000, 10000]; | |
//ActiveShelf -- Used as a counter/progress monitor for keeping track of find | |
var ActiveShelf = 1; | |
//CorrectShelf -- Marks whether shelf has been found, then marks the Shelf # of the correct shelf when found. | |
var CorrectShelf = 0; | |
//InputCallNoComp -- User inputed Call NO translated to all digits as follows: | |
//Dewey 011.111 ABC --> 011.111.000102 | |
var InputCallNoComp = 0; | |
//Alphabet -- Used to convert letters to numbers. Counts 01-26, not 00-25. TrueLetter -- Used to convert. | |
var Alphabet = ["A", "B", "C", "D", "E", "F", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A"]; | |
console.info("TESTING Array Alphabet: " + Alphabet[0] + Alphabet[1] + Alphabet[2] + ". The array is " + "characters long."); | |
var TrueLetter = 0.0; | |
//Gets user input of call number | |
console.info("Please input the call number of your book in the format: 123.456 ABC, then press enter."); | |
var InputCallNoText = InputString; | |
//NEED TO TRANSLATE SCANNER | |
console.info("You inputed: " + InputCallNoText); | |
console.info("Your input is " + InputCallNoText.length + " characters long."); | |
////Converts InputCallNoText to InputCallNoComps | |
//InputNumbers == 123.000 | |
var InputNumbers1 = InputCallNoText.substring(0, 3); | |
console.info("TESTING: The first phrase of your input is: " + InputNumbers1 + "."); | |
InputCallNoComp = parseInt(InputNumbers1); | |
//InputNumbers2 == 000.456 | |
var InputNumbers2 = InputCallNoText.substring(4, 7); | |
var InputCallNoComp2 = parseInt(InputNumbers2); | |
console.info("TESTING: The second phrase of your input is: " + InputCallNoComp2 + "."); | |
InputCallNoComp2 = InputCallNoComp2 / 1000; | |
console.info("TESTING: The second phrase of your input is now: " + InputCallNoComp2 + "."); | |
InputCallNoComp = InputCallNoComp + InputCallNoComp2; | |
console.info("TESTING: The full digits of the call number are: " + InputCallNoComp + "."); | |
//InputAuthName == ABC | |
var InputAuthName = InputCallNoText.substring(8, 11); | |
var InputAuthNameSplit = InputAuthName.split(""); | |
console.info("TESTING: Your Author tag is " + InputAuthName + ", and it is " + InputAuthName.length + " characters long."); | |
console.info("TESTING: Your Author tag is " + InputAuthNameSplit[0] + InputAuthNameSplit[1] + InputAuthNameSplit[2] + ", and it is " + InputAuthName.length + " characters long."); | |
var InputAuthNameNumbers = [0.0, 0.0, 0.0]; | |
for (var AuthName = 0; AuthName < 3; AuthName++) { | |
console.info("TESTING: The letter being checked is the " + AuthName + "th letter and the letter is " + InputAuthNameSplit[AuthName] + "."); | |
for (var Letter = 0; Letter < 25; Letter++) { | |
console.info("TESTING: Checking letter " + AuthName + " against letter " + Alphabet[Letter] + "."); | |
console.info(/* equals */ (function (o1, o2) { if (o1 && o1.equals) { | |
return o1.equals(o2); | |
} | |
else { | |
return o1 === o2; | |
} })(Alphabet[Letter], InputAuthNameSplit[AuthName])); | |
if ((function (o1, o2) { if (o1 && o1.equals) { | |
return o1.equals(o2); | |
} | |
else { | |
return o1 === o2; | |
} })(Alphabet[Letter], InputAuthNameSplit[AuthName])) { | |
console.info("TESTING: The letter was " + Alphabet[Letter]); | |
if (Letter === 0) { | |
TrueLetter = 26; | |
} | |
else { | |
TrueLetter = Letter; | |
} | |
console.info("TESTING: The found letter is: " + InputAuthNameNumbers[AuthName] + "."); | |
InputAuthNameNumbers[AuthName] = TrueLetter; | |
Letter = 27; | |
console.info("TESTING: The found letter is: " + TrueLetter + "."); | |
} | |
} | |
} | |
InputAuthNameNumbers[0] = InputAuthNameNumbers[0] / 100000; | |
console.info("TESTING: The first value is: " + InputAuthNameNumbers[0]); | |
InputCallNoComp = InputCallNoComp + InputAuthNameNumbers[0]; | |
console.info("TESTING: The current Call Number is: " + InputCallNoComp); | |
InputAuthNameNumbers[1] = InputAuthNameNumbers[1] / 10000000; | |
console.info("TESTING: The second value is: " + InputAuthNameNumbers[1]); | |
InputCallNoComp = InputCallNoComp + InputAuthNameNumbers[1]; | |
console.info("TESTING: The current Call Number is: " + InputCallNoComp); | |
InputAuthNameNumbers[2] = InputAuthNameNumbers[2] / 1000000000; | |
console.info("TESTING: The third value is: " + InputAuthNameNumbers[2]); | |
InputCallNoComp = InputCallNoComp + InputAuthNameNumbers[2]; | |
console.info("TESTING: The current Call Number is: " + InputCallNoComp); | |
var Found = false; | |
while ((Found === false)) { | |
if (InputCallNoComp >= FirstCallNo[ActiveShelf] && InputCallNoComp <= LastCallNo[ActiveShelf]) { | |
CorrectShelf = ActiveShelf; | |
Found = true; | |
} | |
else { | |
ActiveShelf++; | |
} | |
} | |
console.info("Our system found your book on shelf " + CorrectShelf + "."); | |
console.info("Here\'s how to get there:"); | |
console.info("If you used this system, please email [email protected] with the subject line: Library Book Finder."); | |
console.info("In the body of your message, please include the call number of the book you were looking for and whether or not this program found the correct location."); | |
}; | |
Main.main(null); | |
return Main; | |
} | |
function getFormData(){ | |
// var InputString=document.getElementById("InputString").value; | |
// /* some other fields */ | |
// /* now call your function by passing the above values */ | |
// createUserWithName(name, email); | |
} | |
getFormData(); | |
Main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment