From 2a8c0cece0f40a9624f8276a625574553ab0ba3e Mon Sep 17 00:00:00 2001 From: Tobi Date: Tue, 9 Apr 2024 10:38:35 +0200 Subject: [PATCH] debugging PWA --- index.html | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/index.html b/index.html index adb62c2..9437d3a 100644 --- a/index.html +++ b/index.html @@ -76,17 +76,6 @@ color: #666; font-size: 12px; } - #installButton { - display: none; - margin: 0 auto; - padding: 10px 20px; - font-size: 16px; - background-color: #4CAF50; - color: #fff; - border: none; - border-radius: 5px; - cursor: pointer; - } #install-instructions { display: none; text-align: center; @@ -104,9 +93,6 @@

2. Tap Add to Home Screen.

- - -
@@ -176,26 +162,15 @@ }); } - function installApp() { - if ('serviceWorker' in navigator) { - navigator.serviceWorker.register('/service-worker.js') - .then(registration => { - console.log('Service Worker registered with scope:', registration.scope); - }) - .catch(error => { - console.error('Service Worker registration failed:', error); - }); - } - - // Hide the installation button once the app is installed - document.getElementById('installButton').style.display = 'none'; - } - // Show installation instructions only if accessed via browser if (!window.matchMedia('(display-mode: standalone)').matches) { document.getElementById('install-instructions').style.display = 'block'; - document.getElementById('installButton').style.display = 'block'; } + + // Detect when the app is launched from the home screen and hide installation instructions + window.addEventListener('appinstalled', (event) => { + document.getElementById('install-instructions').style.display = 'none'; + });