-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
64 lines (54 loc) · 1.18 KB
/
Copy pathscript.js
File metadata and controls
64 lines (54 loc) · 1.18 KB
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
63
64
window.onload = initAll;
var usedNums = new Array(76);
function initAll(){
if(document.getElementById){
document.getElementById('reload').onClick = anotherCard;
newCard();
}
else{
alert("Sorry, your browser sucks!");
}
}
function newCard(){
for(var i=0; i<24; i++){
setSquare(i);
}
}
function setSquare(thisSquare){
var currSquare = "square" + thisSquare;
var colPlace = new Array(0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4);
var colBasis = colPlace[thisSquare]*15;
var newNum;
do{
var newNum = colBasis + getNewNum();
}
while(usedNums[newNum]);
usedNums[newNum] = true;
document.getElementById(currSquare).innerHTML = newNum;
document.getElementById(currSquare).className = "";
document.getElementById(currSquare).onmousedown = toggleColor;
}
function getNewNum(){
return Math.floor( Math.random() * 15 );
}
function anotherCard(){
for(var i =1; i<usedNums.length;i++){
usedNums[i] = false;
}
newCard();
return false;
}
function toggleColor(evt){
if(evt){
var thisSquare = evt.target;
}
else{
var thisSquare = window.event.srcElement;
}
if(thisSquare.className == ""){
thisSquare.className = "pickedBG";
}
else{
thisSquare.className = "";
}
}