Repository navigation
Expand file tree
/
Copy pathmyscripts.js
More file actions
51 lines (50 loc) · 1.61 KB
/
Copy pathmyscripts.js
File metadata and controls
51 lines (50 loc) · 1.61 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
var arr = ['red','purple','royalblue','orange']
function change(value,color){
color=document.getElementById(value).className;
if(value<30){
right=document.getElementById(value+1);
if(value>1){
if(value>6)
topp=document.getElementById(value-6);
left=document.getElementById(value-1);
if(value<25)
bottom=document.getElementById(value+6);
}
}
if(color!='white'){
if(right.className!='white'){
if(left.className!='white'){
if(bottom.className!='white'){
if(topp.className!='white'){
var setcolor = arr[Math.floor(Math.random()*arr.length)]
document.getElementById(value).style.backgroundColor = setcolor;
}
else{
topp.style.backgroundColor = color;
topp.className = color;
document.getElementById(value).className='white';
document.getElementById(value).style.backgroundColor = 'white';
}
}
else{
bottom.style.backgroundColor = color;
bottom.className = color;
document.getElementById(value).className='white';
document.getElementById(value).style.backgroundColor = 'white';
}
}
else{
left.style.backgroundColor = color;
left.className = color;
document.getElementById(value).className='white';
document.getElementById(value).style.backgroundColor = 'white';
}
}
else{
right.style.backgroundColor = color;
right.className = color;
document.getElementById(value).className='white';
document.getElementById(value).style.backgroundColor = 'white';
}
}
}