website: snap

This commit is contained in:
nym21
2026-05-16 22:12:44 +02:00
parent 421e5286ce
commit e5819769e8
11 changed files with 339 additions and 267 deletions

View File

@@ -114,7 +114,7 @@ export function init(selected) {
function startPolling() {
stopPolling();
poll();
pollInterval = setInterval(poll, 5_000);
pollInterval = setInterval(poll, 1_000);
}
function stopPolling() {

View File

@@ -388,7 +388,7 @@ export function initOptions() {
summary.append(node.name);
const count = window.document.createElement("small");
count.textContent = `(${node.count.toLocaleString("en-us")})`;
count.textContent = `[${node.count.toLocaleString("en-us")}]`;
summary.append(count);
let built = false;

View File

@@ -29,7 +29,7 @@ export function initPrice(brk) {
}
poll();
setInterval(poll, 5_000);
setInterval(poll, 1_000);
document.addEventListener("visibilitychange", () => {
!document.hidden && poll();
});

View File

@@ -19,16 +19,33 @@ export function onChange(callback) {
return () => callbacks.delete(callback);
}
const themeButton = /** @type {HTMLButtonElement | null} */ (
document.getElementById("theme-button")
);
let running = false;
/** @param {boolean} value */
function setDark(value) {
if (dark === value) return;
if (running || dark === value) return;
dark = value;
running = true;
if (themeButton) themeButton.disabled = true;
const swap = () => {
apply(value);
callbacks.forEach((cb) => cb());
};
if (document.startViewTransition) document.startViewTransition(swap);
else swap();
document.documentElement.classList.add("no-transitions");
const restore = () => {
document.documentElement.classList.remove("no-transitions");
running = false;
if (themeButton) themeButton.disabled = false;
};
if (document.startViewTransition) {
document.startViewTransition(swap).finished.finally(restore);
} else {
swap();
requestAnimationFrame(restore);
}
}
/** @param {boolean} isDark */
@@ -53,4 +70,4 @@ function invert() {
}
}
document.getElementById("theme-button")?.addEventListener("click", invert);
themeButton?.addEventListener("click", invert);