-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbingo-card.js
executable file
·45 lines (37 loc) · 951 Bytes
/
bingo-card.js
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
window.onload = initAll;
var usedNums = new Array(76);
function initAll() {
if (document.getElementById) {
document.getElementById("reload").onclick = anotherCard;
newCard();
}
else{
alert("Your browser does not support this script.");
}
}
function newCard() {
for(var i=0 ; i<24 ; i++){
setSquare(i);
}
}
function setSquare(thisSquare){
var currentSquare = "square" + thisSquare;
var colPlace = new Array(0,1,2,3,4,0,1,2,3,4,0,1,3,4,0,1,2,3,4,0,1,2,3,4);
var colBasis = colPlace[thisSquare] * 15;
var newNum = colBasis + getNewNum() + 1;
do{
newNum = colBasis + getNewNum() + 1;
}while(usedNums[newNum]);
usedNums[newNum] = true;
document.getElementById(currentSquare).innerHTML = newNum;
}
function getNewNum() {
return Math.floor(Math.random() * 15);
}
function anotherCard() {
for (var i = 1; i < usedNums.length; i++) {
usedNums[i] = false;
};
newCard();
return false;
}