From 95d5b1daa976b6b4b319554be89fd11e6daea454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drix?= Date: Fri, 27 Mar 2026 07:57:08 +0100 Subject: [PATCH] =?UTF-8?q?demande=20de=20garder=20l'=C3=A9cran=20allum?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 2 +- public/script.js | 28 +++++++++++++++++++++++++++- public/sw.js | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index 53c663e..13109a5 100644 --- a/public/index.html +++ b/public/index.html @@ -16,7 +16,7 @@
- v1.206 + v1.207
diff --git a/public/script.js b/public/script.js index 45df01f..86402d0 100644 --- a/public/script.js +++ b/public/script.js @@ -1,6 +1,7 @@ let isEditMode = false; let editingIndex = null; let tempFileData = null; + let wakeLock = null; let deferredPrompt; const installBtn = document.getElementById('installBtn'); @@ -94,6 +95,30 @@ init(); } + // Fonction pour demander le verrouillage de l'écran + async function requestWakeLock() { + try { + if ('wakeLock' in navigator) { + wakeLock = await navigator.wakeLock.request('screen'); + console.log("L'écran est verrouillé (ne s'éteindra pas)"); + + // Si le verrouillage est libéré (ex: perte de focus), on le réinitialise + wakeLock.addEventListener('release', () => { + console.log("Le verrouillage de l'écran a été libéré"); + }); + } + } catch (err) { + console.error(`${err.name}, ${err.message}`); + } + } + + // Réactiver le verrouillage quand l'app revient au premier plan + document.addEventListener('visibilitychange', async () => { + if (wakeLock !== null && document.visibilityState === 'visible') { + await requestWakeLock(); + } + }); + function init() { const board = document.getElementById('board'); board.innerHTML = ""; @@ -216,4 +241,5 @@ navigator.serviceWorker.register('sw.js') .then(() => console.log("Service Worker Enregistré")); } - \ No newline at end of file + + requestWakeLock(); \ No newline at end of file diff --git a/public/sw.js b/public/sw.js index 1a139f8..31ab707 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1,4 +1,4 @@ -const CACHE_NAME = 'sb-v1.206'; // Change ce numéro pour forcer une mise à jour globale +const CACHE_NAME = 'sb-v1.207'; // Change ce numéro pour forcer une mise à jour globale const ASSETS = [ './', // Racine './index.html',