-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
64 lines (53 loc) · 1.83 KB
/
script.js
File metadata and controls
64 lines (53 loc) · 1.83 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
55
56
57
58
59
60
61
62
63
64
/* ── Countdown ── */
const LAUNCH = new Date("2026-12-31T00:00:00").getTime();
function pad(n) {
return String(n).padStart(2, "0");
}
function updateCountdown() {
const now = Date.now();
const diff = Math.max(0, LAUNCH - now);
const totalSeconds = Math.floor(diff / 1000);
const totalMinutes = Math.floor(totalSeconds / 60);
const totalHours = Math.floor(totalMinutes / 60);
const totalDays = Math.floor(totalHours / 24);
const totalWeeks = Math.floor(totalDays / 7);
const weeks = totalWeeks;
const days = totalDays % 7;
const hours = totalHours % 24;
const minutes = totalMinutes % 60;
const seconds = totalSeconds % 60;
const elWeeks = document.getElementById("weeks");
const elDays = document.getElementById("days");
const elHours = document.getElementById("hours");
const elMinutes = document.getElementById("minutes");
const elSeconds = document.getElementById("seconds");
function setVal(el, newVal) {
const v = pad(newVal);
if (el && el.textContent !== v) {
el.textContent = v;
el.style.transform = "scale(1.15)";
setTimeout(() => {
if (el) el.style.transform = "scale(1)";
}, 150);
}
}
setVal(elWeeks, weeks);
setVal(elDays, days);
setVal(elHours, hours);
setVal(elMinutes, minutes);
setVal(elSeconds, seconds);
}
updateCountdown();
setInterval(updateCountdown, 1000);
/* ── Theme Toggle ── */
const html = document.documentElement;
const themeToggle = document.getElementById("themeToggle");
// Load saved preference
const saved = localStorage.getItem("theme") || "dark";
html.setAttribute("data-theme", saved);
themeToggle.addEventListener("click", () => {
const current = html.getAttribute("data-theme");
const next = current === "dark" ? "light" : "dark";
html.setAttribute("data-theme", next);
localStorage.setItem("theme", next);
});