-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
52 lines (49 loc) · 1.45 KB
/
scripts.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
46
47
48
49
50
51
52
const container = document.getElementById("container");
function makeRows(rows, cols) {
container.style.setProperty('--grid-rows', rows);
container.style.setProperty('--grid-cols', cols);
for (c = 0; c < (rows * cols); c++) {
let cell = document.createElement("div");
container.appendChild(cell).className = "grid-item";
};
};
start.addEventListener('click', function (e) {
let size = prompt("Please select the size of the grid (max 50)");
let count = 0;
loop:
while(true){
if(size <= 50){
break loop;
}
else if (size > 50 && count == 0){
size = prompt("Please enter a maximum size of 50");
count ++;
}
else if (size > 50 && count == 1){
size = prompt("Can't you read? Please enter a maximum size of 50");
count ++;
}
else if (size > 50 && count == 2){
size = prompt("Seriously bro? The maximum is 50");
count ++;
}
else{
size = prompt("OMG PLEASE ENTER A MAXIMUM OF 50!!!");
}
}
makeRows(size, size);
$(".grid-item").css("background-color", "white");
$(".grid-item").hover(function(){
$(this).css("background-color", "yellow");
}, function(){
$(this).css("background-color", "black");
});
});
reset.addEventListener('click', function (e) {
$(".grid-item").css("background-color", "white");
$(".grid-item").hover(function(){
$(this).css("background-color", "yellow");
}, function(){
$(this).css("background-color", "black");
});
});