Block repeated on while auto-off is active

This commit is contained in:
2026-08-03 01:37:14 +02:00
parent 4ea737024b
commit 6b2bc3853a
8 changed files with 204 additions and 6 deletions
@@ -213,6 +213,45 @@ select {
object-fit: cover;
}
.snapshot-refresh {
position: absolute;
top: 12px;
right: 12px;
display: grid;
width: 38px;
height: 38px;
place-items: center;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 6px;
background: rgba(15, 23, 42, 0.72);
color: #ffffff;
cursor: pointer;
box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
}
.snapshot-refresh:hover {
background: rgba(15, 23, 42, 0.88);
}
.snapshot-refresh:focus-visible {
outline: 3px solid rgba(29, 78, 216, 0.35);
outline-offset: 2px;
}
.snapshot-refresh.is-refreshing svg {
animation: refresh-spin 0.9s linear infinite;
}
.snapshot-refresh svg {
width: 20px;
height: 20px;
fill: none;
stroke: currentColor;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 2;
}
.media-empty {
display: grid;
place-items: center;
@@ -514,6 +553,13 @@ h3 {
outline-offset: 2px;
}
.cmd:disabled {
border-color: var(--line);
background: #eef2f6;
color: #8290a2;
cursor: not-allowed;
}
.cmd-on,
.cmd-press {
border-color: var(--blue);
@@ -521,12 +567,24 @@ h3 {
color: #ffffff;
}
.cmd-on:disabled {
border-color: var(--line);
background: #eef2f6;
color: #8290a2;
}
.cmd-on:hover,
.cmd-press:hover {
border-color: var(--blue-dark);
background: var(--blue-dark);
}
.cmd-on:disabled:hover {
border-color: var(--line);
background: #eef2f6;
color: #8290a2;
}
.cmd-off {
border-color: #9dd8bd;
background: #ffffff;
@@ -100,6 +100,39 @@ async function handleRefreshSubmit(form, event) {
}
}
function refreshSnapshot(button) {
if (button.classList.contains("is-refreshing")) {
return;
}
const media = button.closest(".media");
const image = media?.querySelector("img.snapshot");
if (!image) {
return;
}
const url = new URL(image.currentSrc || image.src, window.location.href);
url.searchParams.set("refresh", "1");
url.searchParams.set("v", String(Date.now()));
const cleanup = () => {
button.disabled = false;
button.classList.remove("is-refreshing");
button.removeAttribute("aria-busy");
};
button.disabled = true;
button.classList.add("is-refreshing");
button.setAttribute("aria-busy", "true");
image.addEventListener("load", cleanup, { once: true });
image.addEventListener("error", cleanup, { once: true });
image.src = url.toString();
}
document.addEventListener("click", (event) => {
const button = event.target.closest(".snapshot-refresh");
if (!(button instanceof HTMLButtonElement)) {
return;
}
refreshSnapshot(button);
});
document.addEventListener("submit", (event) => {
const form = event.target;
if (!(form instanceof HTMLFormElement)) {