diff --git a/index.html b/index.html index 61b8e4a..6a14c28 100644 --- a/index.html +++ b/index.html @@ -96,14 +96,30 @@ padding: 20px; } + + -
+ - + + +

Exchange Rate Calculator

@@ -185,20 +201,27 @@ let deferredPrompt; window.addEventListener('beforeinstallprompt', (event) => { + // Prevent the default installation prompt event.preventDefault(); + // Stash the event so it can be triggered later deferredPrompt = event; + // Show installation instructions only if app is not already installed if (!window.matchMedia('(display-mode: standalone)').matches) { - document.getElementById('install-instructions').style.display = 'block'; + document.getElementById('install-instructions').classList.add('show'); + document.getElementById('installButton').style.display = 'block'; } }); function installApp() { + // Show the installation prompt when the user clicks the button if (deferredPrompt) { deferredPrompt.prompt(); deferredPrompt.userChoice.then((choiceResult) => { if (choiceResult.outcome === 'accepted') { console.log('User accepted the A2HS prompt'); - document.getElementById('install-instructions').style.display = 'none'; + // App installed, hide installation instructions + document.getElementById('install-instructions').classList.remove('show'); + document.getElementById('installButton').style.display = 'none'; } deferredPrompt = null; }); @@ -206,6 +229,7 @@ } +