demande de garder l'écran allumé

This commit is contained in:
2026-03-27 07:57:08 +01:00
parent 4c390c933d
commit 95d5b1daa9
3 changed files with 29 additions and 3 deletions

View File

@@ -16,7 +16,7 @@
<header> <header>
<div style="display: flex; gap: 10px; align-items: center;"> <div style="display: flex; gap: 10px; align-items: center;">
<button class="stop-all" onclick="stopAll()">🛑 STOP ALL</button> <button class="stop-all" onclick="stopAll()">🛑 STOP ALL</button>
<span id="app-version" style="color: #555; font-size: 0.8rem; margin-left: 10px;">v1.206</span> <span id="app-version" style="color: #555; font-size: 0.8rem; margin-left: 10px;">v1.207</span>
<button id="installBtn" style="display:none; ...">📥 INSTALLER</button> <button id="installBtn" style="display:none; ...">📥 INSTALLER</button>
</div> </div>

View File

@@ -1,6 +1,7 @@
let isEditMode = false; let isEditMode = false;
let editingIndex = null; let editingIndex = null;
let tempFileData = null; let tempFileData = null;
let wakeLock = null;
let deferredPrompt; let deferredPrompt;
const installBtn = document.getElementById('installBtn'); const installBtn = document.getElementById('installBtn');
@@ -94,6 +95,30 @@
init(); 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() { function init() {
const board = document.getElementById('board'); const board = document.getElementById('board');
board.innerHTML = ""; board.innerHTML = "";
@@ -217,3 +242,4 @@
.then(() => console.log("Service Worker Enregistré")); .then(() => console.log("Service Worker Enregistré"));
} }
requestWakeLock();

View File

@@ -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 = [ const ASSETS = [
'./', // Racine './', // Racine
'./index.html', './index.html',