-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
54 lines (41 loc) · 1.5 KB
/
script.js
File metadata and controls
54 lines (41 loc) · 1.5 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
let workTitle = document.getElementById('fokus');
let breakTitle = document.getElementById('istirahat');
let waktuFokus = 25;
let waktuIstirahat = 5;
let detik = "00";
window.onload = () => {
document.getElementById('menit').innerHTML = waktuFokus;
document.getElementById('detik').innerHTML = detik;
workTitle.classList.add('aktif');
}
function mulai(){
document.getElementById('mulai').style.display = "none";
document.getElementById('reset').style.display = "block";
detik = 59;
let menitFokus = waktuFokus - 1;
let menitIstirahat = waktuIstirahat - 1;
breakCount = 0;
let timerFunction =()=> {
document.getElementById('menit').innerHTML = menitFokus.toString().padStart(2, '0');
document.getElementById('detik').innerHTML = detik.toString().padStart(2, '0');
detik = detik - 1;
if(detik === 0){
menitFokus = menitFokus - 1;
if(menitFokus === -1){
if(breakCount % 2 === 0){
menitFokus = menitIstirahat;
breakCount++;
workTitle.classList.remove('aktif');
breakTitle.classList.add('aktif');
}else{
menitFokus = waktuFokus;
breakCount++;
breakTitle.classList.remove('aktif');
workTitle.classList.add('aktif');
}
}
detik =59;
}
}
setInterval(timerFunction, 1000);
}