-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (29 loc) · 832 Bytes
/
script.js
File metadata and controls
37 lines (29 loc) · 832 Bytes
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
const $ = (selector) => {
return document.querySelector(selector);
};
const hour = $(".hour");
const dots = document.querySelectorAll(".dot");
const min = $(".min");
const sec = $(".sec");
const week = $(".week");
let showDot = true;
function update() {
const now = new Date();
showDot = !showDot;
dots.forEach((dot) => {
if (showDot) {
dot.classList.add("invisible");
} else {
dot.classList.remove("invisible");
}
});
hour.textContent = String(now.getHours()).padStart(2, "0");
min.textContent = String(now.getMinutes()).padStart(2, "0");
sec.textContent = String(now.getSeconds()).padStart(2, "0");
Array.from(week.children).forEach((ele) => {
ele.classList.remove("active");
});
week.children[now.getDay()].classList.add("active");
}
setInterval(update, 1000);
update();