timer.js
1.09 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
var x;
const onClick = (bt) => {
const onDelete = () => {
clearInterval(x);
document.getElementById("demo").innerText = "";
document.querySelector("#deleteBtn").innerText = "";
document.querySelector("#healthname").innerText = "";
};
const a = document.querySelector("#breaktime").innerText;
var time = parseInt(bt.value);
console.log(bt.name);
console.log(time);
var min = "";
var sec = "";
x = setInterval(function () {
min = parseInt(time / 60);
sec = time % 60;
document.getElementById("demo").innerHTML = min + ":" + sec + "";
time--;
if (time < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "쉬는시간 끝!";
alert("쉬는시간이 끝났습니다!");
}
}, 1000);
const del_bt = document.querySelector("#deleteBtn");
const healthname = document.querySelector("#healthname");
healthname.innerHTML = bt.name + " 쉬는시간!";
var ex = document.createElement("Button");
ex.innerHTML = "타이머 지우기";
ex.className = "btn btn-dark";
ex.onclick = onDelete;
del_bt.appendChild(ex);
};