-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path220711.html
More file actions
87 lines (74 loc) · 1.65 KB
/
220711.html
File metadata and controls
87 lines (74 loc) · 1.65 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
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
}
.wrapper {
place-items: center;
background: lightgrey;
display: grid;
height: 100vh;
}
.info {
text-align: center;
text-size: 40px;
}
.circle {
height: 400px;
width: 400px;
border-radius: 50%;
background: #c51212cc;
}
.start {
text-align: center;
width: 75px;
height: 50px;
text-size: 20px;
visibility: visible;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="info">0 ms</div>
<div class="circle"></div>
<div>
<button class="start">START</button>
</div>
</div>
<script>
const score = document.querySelector(".info");
const circle = document.querySelector(".circle");
const start = document.querySelector(".start");
let time;
let flag=false;
let timeout;
circle.addEventListener("click", click);
start.addEventListener("click", btn);
function click() {
if (flag) {
flag = false;
circle.style.background = '#c51212cc';
score.innerText = new Date().getTime() - time + " ms";
}else{
alert("너무 빠릅니다!");
clearTimeout(timeout);
}
start.style.visibility = 'visible';
}
function btn() {
clearTimeout(timeout);
start.style.visibility = 'hidden';
var ranTime = 2000 + Math.floor(Math.random() * 16) * 100
timeout = setTimeout(() => {
flag=true;
circle.style.background = '#12c512cc';
time = new Date().getTime();
}, ranTime);
}
</script>
</body>
</html>