-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
36 lines (29 loc) · 973 Bytes
/
script.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
function updateClock() {
const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
document.getElementById('hours').textContent = hours;
document.getElementById('minutes').textContent = minutes;
}
function setTheme(theme) {
document.body.className = theme;
localStorage.setItem('clockworkTheme', theme);
}
function initTheme() {
const savedTheme = localStorage.getItem('clockworkTheme');
if (savedTheme) {
setTheme(savedTheme);
document.getElementById('themeSelector').value = savedTheme;
}
}
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('themeSelector').addEventListener('change', (e) => {
setTheme(e.target.value);
});
// Update clock every second
setInterval(updateClock, 1000);
// Initial clock update
updateClock();
// Initialize theme
initTheme();
});