48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
|
// TODO
|
||
|
|
||
|
let numberOfSecond
|
||
|
|
||
|
let id_interval
|
||
|
|
||
|
let btt = document.getElementsByTagName("button")[0]
|
||
|
let p = document.getElementsByTagName("p")[0]
|
||
|
let text_numberOfSecond = document.getElementsByTagName("p")[0].lastElementChild
|
||
|
let figure = document.getElementsByTagName("figure")[0]
|
||
|
let numberOfClick = document.getElementsByTagName("figure")[0].lastElementChild
|
||
|
|
||
|
|
||
|
function Timer(e4) {
|
||
|
numberOfSecond--;
|
||
|
text_numberOfSecond.innerText = numberOfSecond + " seconds left!"
|
||
|
}
|
||
|
|
||
|
function Ending(e3) {
|
||
|
figure.removeEventListener("click", ClickIMG, false)
|
||
|
|
||
|
clearInterval(id_interval)
|
||
|
text_numberOfSecond.innerText = 0 + " second left!"
|
||
|
}
|
||
|
|
||
|
function ClickIMG(e2) {
|
||
|
numberOfClick.innerText = Number(numberOfClick.innerText) + 1
|
||
|
}
|
||
|
|
||
|
function ReponseClick(e1) {
|
||
|
numberOfSecond = 15
|
||
|
btt.classList.add("hidden")
|
||
|
p.classList.remove("hidden")
|
||
|
text_numberOfSecond.innerText = numberOfSecond + " seconds left!"
|
||
|
text_numberOfSecond.style = "color:red"
|
||
|
|
||
|
figure.addEventListener("click", ClickIMG, false)
|
||
|
|
||
|
id_interval = setInterval(Timer, 1000)
|
||
|
|
||
|
setTimeout(Ending, 15000)
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
btt.addEventListener("click", ReponseClick, false)
|
||
|
|