-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (34 loc) · 986 Bytes
/
app.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
let clicks = 0;
let max_clicks = 0;
let reset_percent = 0;
function buttonClick() {
clicks += 1;
update();
}
function update() {
if (clicks > max_clicks) {
max_clicks = clicks
}
reset_percent = clicks
document.getElementById('score').innerText = clicks
reset();
}
function reset() {
if (Math.random() < reset_percent / 100) {
reset_percent = 0;
clicks = 0;
reset_anim();
}
}
function reset_anim() {
document.getElementById('cover').className = 'absolute bg-red-700 h-0 w-screen top-[-100%] transition-all duration-500 animation';
const animated = document.getElementById('cover');
animated.onanimationend = () => {
document.getElementById('cover').className = 'absolute bg-red-700 h-0 w-screen hidden top-[-100%] transition-all duration-500';
reset_end();
};
}
function reset_end() {
document.getElementById('max_score').innerText = max_clicks;
update();
}