-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocaltest.html
62 lines (59 loc) · 2.38 KB
/
localtest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE />
<html>
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var alphabet = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 123456789 {} +-=*/\'[]<>|&^%$#@!,?.";
var i = 0;
var curWord = "";
var tot = 0;
localStorage["sameSpot"] = null;
$("#same").bind("click", function () {
var write = function () {
if (!localStorage["sameSpot"])
localStorage["sameSpot"] = alphabet[i++];
else {
curWord = alphabet[i++] + localStorage["sameSpot"];
localStorage["sameSpot"] = curWord;
}
if (i == alphabet.length)
i = 0;
tot++;
$("#local").html(curWord);
$("#memory").html(localStorage["sameSpot"]);
$("p").html("The number of characters written to localStorage[\"sameSpot\"] is: " + tot);
setTimeout(write, 1);
};
write();
});
var tot2 = 0;
var totChars = 0;
$("#different").bind("click", function () {
var write = function () {
var saveObj = {
alphabet: alphabet + alphabet + alphabet + alphabet + alphabet + alphabet + alphabet + alphabet + alphabet + alphabet + alphabet + alphabet,
date: new Date(),
random: Math.random()
};
saveObj = JSON.stringify(saveObj);
totChars += saveObj.length;
localStorage["t" + tot2] = saveObj;
$("#local").html(saveObj);
$("#memory").html(localStorage["t" + tot2]);
tot2++;
$("p").html("The number of unique entries made in localStorage[0++] is " + tot2 + " and the total number of characters is: " + totChars + " with an average of " + Math.floor(totChars / tot2) + " characters per record");
setTimeout(write, 1);
};
write();
});
});
</script>
<body>
<button id="same">Write Chars To Same Spot</button>
<button id="different">Write Chars To Same Spot</button>
<br />
<p></p>
<textarea rows="50" cols="100" id="memory"></textarea>
<textarea rows="50" cols="100" id="local"></textarea>
</body>
</html>