From 04c7ac4142826d2e118d6750e83471e910aeaa4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drix?= Date: Fri, 27 Mar 2026 01:55:18 +0100 Subject: [PATCH] message pour firefox --- public/index.html | 2 +- public/script.js | 53 ++++++++++++++++++++++++++++------------------- public/sw.js | 2 +- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/public/index.html b/public/index.html index 364fe01..5230a9c 100644 --- a/public/index.html +++ b/public/index.html @@ -16,7 +16,7 @@
- v1.201 + v1.203
diff --git a/public/script.js b/public/script.js index 5568919..17fabe3 100644 --- a/public/script.js +++ b/public/script.js @@ -4,28 +4,38 @@ let deferredPrompt; const installBtn = document.getElementById('installBtn'); + const isFirefox = typeof InstallTrigger !== 'undefined'; window.addEventListener('beforeinstallprompt', (e) => { - // EmpĂȘche Chrome d'afficher sa propre mini-barre - e.preventDefault(); - // Stocke l'Ă©vĂ©nement pour l'utiliser plus tard - deferredPrompt = e; - // Affiche votre bouton personnalisĂ© - installBtn.style.display = 'block'; + // EmpĂȘche Chrome d'afficher sa propre mini-barre + e.preventDefault(); + // Stocke l'Ă©vĂ©nement pour l'utiliser plus tard + deferredPrompt = e; + // Affiche votre bouton personnalisĂ© + installBtn.style.display = 'block'; - installBtn.addEventListener('click', async () => { - if (deferredPrompt) { - // Montre la fenĂȘtre d'installation native - deferredPrompt.prompt(); - // Attend la rĂ©ponse de l'utilisateur - const { outcome } = await deferredPrompt.userChoice; - console.log(`L'utilisateur a rĂ©pondu : ${outcome}`); - // On nettoie - deferredPrompt = null; - installBtn.style.display = 'none'; + installBtn.addEventListener('click', async () => { + if (deferredPrompt) { + // Montre la fenĂȘtre d'installation native + deferredPrompt.prompt(); + // Attend la rĂ©ponse de l'utilisateur + const { outcome } = await deferredPrompt.userChoice; + console.log(`L'utilisateur a rĂ©pondu : ${outcome}`); + // On nettoie + deferredPrompt = null; + installBtn.style.display = 'none'; + } + }); + }); + + if (isFirefox && !window.matchMedia('(display-mode: standalone)').matches) { + // On peut par exemple afficher un petit texte dans le header + const infoZone = document.getElementById('app-version'); // On utilise la zone de version + if (infoZone) { + infoZone.innerHTML += "
(Install. non dispo sur Firefox PC)"; + infoZone.style.color = "#ff8800"; // Orange pour attirer l'oeil gentiment } - }); - }); + } // Cache le bouton si l'app est déjà installée window.addEventListener('appinstalled', () => { @@ -196,6 +206,7 @@ init(); if ('serviceWorker' in navigator) { - navigator.serviceWorker.register('sw.js') - .then(() => console.log("Service Worker Enregistré")); - } \ No newline at end of file + navigator.serviceWorker.register('sw.js') + .then(() => console.log("Service Worker Enregistré")); + } + \ No newline at end of file diff --git a/public/sw.js b/public/sw.js index 6eed1fa..952ffda 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1,4 +1,4 @@ -const CACHE_NAME = 'sb-v1.201'; // Change ce numéro pour forcer une mise à jour globale +const CACHE_NAME = 'sb-v1.203'; // Change ce numéro pour forcer une mise à jour globale const ASSETS = [ './', // Racine './index.html',