add screen to view a barcode isolated

This commit is contained in:
2026-08-08 16:35:54 -04:00
parent 35de0e1990
commit 58200b2bf9
10 changed files with 274 additions and 11 deletions
+30
View File
@@ -0,0 +1,30 @@
// Keep the screen awake while a rewards barcode is on screen so the cashier
// can scan it without the display dimming or locking. This mirrors how wallet
// apps behave when showing a barcode. The Screen Wake Lock API is best-effort:
// it may be rejected (e.g. low battery) or auto-released when the tab is hidden,
// so we re-acquire whenever the page becomes visible again.
(function () {
var wakeLock = null;
function requestWakeLock() {
if (!("wakeLock" in navigator)) return;
navigator.wakeLock
.request("screen")
.then(function (sentinel) {
wakeLock = sentinel;
})
.catch(function () {
// Best-effort only; ignore failures (unsupported, low battery, etc.).
});
}
// Re-acquire if the lock was released (e.g. the tab was hidden) and the user
// returns to the page.
document.addEventListener("visibilitychange", function () {
if (document.visibilityState === "visible" && wakeLock === null) {
requestWakeLock();
}
});
requestWakeLock();
})();