// 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(); })();