Add wake lock to prevent screen sleep on mobile

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jon
2026-06-12 16:55:20 +01:00
parent 3abd43bdfe
commit 4f2346b28e
2 changed files with 27 additions and 10 deletions

View File

@@ -400,7 +400,15 @@ function toggleUnit() {
document.getElementById('big-speed-unit').textContent=unit;
}
window.addEventListener('DOMContentLoaded', () => startDashcam());
let wakeLock = null;
async function requestWakeLock() {
try { wakeLock = await navigator.wakeLock.request('screen'); } catch(e) {}
}
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') requestWakeLock();
});
window.addEventListener('DOMContentLoaded', () => { startDashcam(); requestWakeLock(); });
function toggleFullscreen() {
const app=document.getElementById('app'), btn=document.getElementById('fs-btn');