feat(fusion_clock): NFC kiosk Wake Lock to keep screen on while active
This commit is contained in:
@@ -410,6 +410,43 @@
|
|||||||
return canvasEl.toDataURL("image/jpeg", 0.7);
|
return canvasEl.toDataURL("image/jpeg", 0.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ──────────────────────────────────────────────────────────────
|
||||||
|
// Wake Lock — keeps the screen on while the kiosk page is active.
|
||||||
|
// Released automatically on tab close/navigation; re-acquired on
|
||||||
|
// visibilitychange when the page comes back to the foreground.
|
||||||
|
// ──────────────────────────────────────────────────────────────
|
||||||
|
let wakeLock = null;
|
||||||
|
|
||||||
|
async function acquireWakeLock() {
|
||||||
|
if (!("wakeLock" in navigator)) {
|
||||||
|
debugLog("wakeLock: API not supported on this browser");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (wakeLock) {
|
||||||
|
debugLog("wakeLock: already held, skipping");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
wakeLock = await navigator.wakeLock.request("screen");
|
||||||
|
debugLog("wakeLock: acquired ✓ (screen will stay on)");
|
||||||
|
wakeLock.addEventListener("release", () => {
|
||||||
|
debugLog("wakeLock: released by browser/OS");
|
||||||
|
wakeLock = null;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
debugLog("wakeLock: request failed: " + (e && e.message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("visibilitychange", async () => {
|
||||||
|
if (document.visibilityState === "visible") {
|
||||||
|
debugLog("visibility: visible — re-acquiring wakeLock");
|
||||||
|
await acquireWakeLock();
|
||||||
|
} else {
|
||||||
|
debugLog("visibility: " + document.visibilityState);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ──────────────────────────────────────────────────────────────
|
// ──────────────────────────────────────────────────────────────
|
||||||
// Setup wizard activation
|
// Setup wizard activation
|
||||||
// ──────────────────────────────────────────────────────────────
|
// ──────────────────────────────────────────────────────────────
|
||||||
@@ -428,6 +465,7 @@
|
|||||||
if (photoRequired) throw camErr;
|
if (photoRequired) throw camErr;
|
||||||
console.warn("[nfc-kiosk] camera unavailable, continuing (photo not required)", camErr);
|
console.warn("[nfc-kiosk] camera unavailable, continuing (photo not required)", camErr);
|
||||||
}
|
}
|
||||||
|
await acquireWakeLock();
|
||||||
setState(STATE.IDLE);
|
setState(STATE.IDLE);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
stateContainer.innerHTML = `
|
stateContainer.innerHTML = `
|
||||||
|
|||||||
Reference in New Issue
Block a user