mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-19 14:24:47 -07:00
website: snap
This commit is contained in:
@@ -114,7 +114,7 @@ export function init(selected) {
|
||||
function startPolling() {
|
||||
stopPolling();
|
||||
poll();
|
||||
pollInterval = setInterval(poll, 5_000);
|
||||
pollInterval = setInterval(poll, 1_000);
|
||||
}
|
||||
|
||||
function stopPolling() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -29,7 +29,7 @@ export function initPrice(brk) {
|
||||
}
|
||||
|
||||
poll();
|
||||
setInterval(poll, 5_000);
|
||||
setInterval(poll, 1_000);
|
||||
document.addEventListener("visibilitychange", () => {
|
||||
!document.hidden && poll();
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user