-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
83 lines (73 loc) · 1.38 KB
/
index.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<style>
#vip{
background:gray;
margin:10px;
width:300px;
height:200px;
}
.v{
background:white;
width:60px;
height:47px;
margin-top:30px;
margin-left:29px;
font-size:30px;
text-align:center;
padding-top:13px;
float:left;
}
#b{
position:absolute;
margin-top:120px;
margin-left:30px;
font-size:30px;
cursor:pointer;
}
</style>
<script>
var nya = 0;
var obj = new Array(3);
var timer = new Array(3);
var loop = new Array(3);
function start(num){
for(var i=0;i<3;i++){
timer[i] = setInterval(loop[i],num);
}
}
function stop(){
clearInterval(timer[nya]);
nya++;
if(nya==3){
if(obj[0].innerHTML==obj[1].innerHTML && obj[0].innerHTML==obj[2].innerHTML){
alert("おめでと!!!");
}else{
alert("ざんねん・・・");
}
start(40);
nya = 0;
}
}
function osoi(){
for(var i=0;i<3;i++){
clearInterval(timer[i]);
}
start(800);
nya = 0;
}
window.onload=function(){
for(var i=0;i<3;i++){
obj[i] = document.getElementById("v"+(i+1));
}
loop[0] = function(){obj[0].innerHTML=Math.floor(Math.random()*10)};
loop[1] = function(){obj[1].innerHTML=Math.floor(Math.random()*10)};
loop[2] = function(){obj[2].innerHTML=Math.floor(Math.random()*10)};
start(40);
}
</script>
<div id="vip">
<div id="v1" class="v">1</div>
<div id="v2" class="v">1</div>
<div id="v3" class="v">1</div>
<div id="b" onClick="stop()">●</div>
</div>
<p onclick="osoi()">..</p>