Created
December 20, 2012 20:33
-
-
Save fulminator/4348321 to your computer and use it in GitHub Desktop.
books list library js
This file contains 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
$(document).ready(function(e) { | |
//localStorage.clear(); | |
var c = $("#content"); | |
var txtNr = $("#txtNr"); | |
var butNr = $("#butNr"); | |
var count = 0; | |
var booksBought = []; | |
var books = [309, | |
365, | |
428, | |
481, | |
482, | |
483, | |
484, | |
488, | |
489, | |
490, | |
491, | |
492, | |
720, | |
835, | |
837, | |
838, | |
844, | |
845, | |
891, | |
904, | |
905, | |
930, | |
973, | |
974, | |
976, | |
989, | |
1012, | |
1071, | |
1104, | |
1128, | |
1129, | |
1152, | |
1194, | |
1120, | |
1145, | |
1305, | |
1347, | |
1351 | |
// write here new book number | |
]; | |
butNr.click( | |
function () { | |
if ((txtNr.val() == "") || (isNaN(txtNr.val()))) { | |
txtNr.val("Not valid!"); | |
} else { | |
booksBought.push($('#txtNr').val()); | |
localStorage['booksBought'] += booksBought; | |
for (var i = 0; i < localStorage.length; i++){ | |
alert(localStorage.getItem(localStorage.key(i))); | |
} | |
} | |
}); | |
for (var i = 1; i <= 1500; i++) { | |
if (books.indexOf(i) >= 0) { | |
c.append("<span style='color:red;'>" + i + "</span><br />"); | |
count++; | |
} | |
else { | |
c.append(i + "<br />"); | |
} | |
} | |
document.title = "biblioteca pentru toti: " + count + "/1500 carti"; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment