-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (35 loc) · 949 Bytes
/
index.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
let coin =document.querySelector(".coin");
let flpbtn = document.querySelector("#button");
let result = document.querySelector("#result");
let r="-----";
document.addEventListener("contextmenu", function(e){
e.preventDefault();
}, false);
flpbtn.addEventListener("click",()=>{
let x = Math.floor(Math.random()*2);
coin.style.animation = "none";
if (x){
setTimeout(function(){
coin.style.animation ="spin-heads 3s forwards";
},0);
r="Heads";
}
else{
setTimeout(function(){
coin.style.animation ="spin-tails 3s forwards";
},0);
r="Tails";
}
setTimeout(updateResult,3000);
disableButton();
});
function updateResult(){
result.textContent = r;
}
function disableButton(){
result.textContent = "-----";
flpbtn.classList.add('disabled');
setTimeout(function(){
flpbtn.classList.remove('disabled');
},3000)
}