-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path220713.html
More file actions
74 lines (67 loc) · 2.17 KB
/
220713.html
File metadata and controls
74 lines (67 loc) · 2.17 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
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<style>
*{
padding: 0;
margin: 0;
}
body{
height: 100vh;
display: grid;
place-items: center;
background: lightgrey;
}
.score{
text-align: center;
text-size: 70px;
}
.circle{
height: 400px;
width: 400px;
border-radius: 50%;
background: #c51212cc;
}
.start{
text-size: 70px;
text-align: center;
}
</style>
</head>
<body ondragstart="return false" onselectstart="return false" oncontextmenu="return false">
<div class="score">0 ms</div>
<div class="circle"></div>
<div class="start">START</div>
<script>
const score = document.querySelector(".score");
const circle = document.querySelector(".circle");
const btn = document.querySelector(".start");
circle.addEventListener("click", click);
btn.addEventListener("click", start);
var time;
var flag = false;
var timeout;
function click(){
if(flag){
flag=false;
score.innerText = new Date().getTime() - time + " ms";
circle.style.background = "#c51212cc";
}else if(btn.style.visibility == "hidden"){
alert("너무 빠릅니다!");
clearTimeout(timeout);
}
btn.style.visibility = "visible";
}
function start(){
btn.style.visibility = "hidden";
clearTimeout(timeout);
const ran = 2000 + Math.floor(Math.random()*16)*100;
timeout = setTimeout(() => {
flag=true;
circle.style.background = "#12c512cc";
time = new Date().getTime();
}, ran);
}
</script>
</body>
</html>