Scope for testing

Signed-off-by: OmegaRogue <thatomegarogue@gmail.com>
pull/228/head
OmegaRogue 2020-04-04 12:57:10 +02:00
parent 1358283f6b
commit 68cd71344b
2 changed files with 34 additions and 1 deletions

View File

@ -1,6 +1,38 @@
const divInstall = document.getElementById('installContainer');
const butInstall = document.getElementById('butInstall');
window.addEventListener('beforeinstallprompt', (event) => {
console.log('👍', 'beforeinstallprompt', event);
// Stash the event so it can be triggered later.
window.deferredPrompt = event;
// Remove the 'hidden' class from the install button container
divInstall.classList.toggle('hidden', false);
});
butInstall.addEventListener('click', () => {
console.log('👍', 'butInstall-clicked');
const promptEvent = window.deferredPrompt;
if (!promptEvent) {
// The deferred prompt isn't available.
return;
}
// Show the install prompt.
promptEvent.prompt();
// Log the result
promptEvent.userChoice.then((result) => {
console.log('👍', 'userChoice', result);
// Reset the deferred prompt variable, since
// prompt() can only be called once.
window.deferredPrompt = null;
// Hide the install button.
divInstall.classList.toggle('hidden', true);
});
});
window.addEventListener('appinstalled', (event) => {
console.log('👍', 'appinstalled', event);
});
/* Only register a service worker if it's supported */
if ('serviceWorker' in navigator) {

View File

@ -17,5 +17,6 @@
"theme_color": "#5755d9",
"background_color": "#5755d9",
"display": "standalone",
"start_url": "https://omegavoid.github.io/BangleApps"
"start_url": "/BangleApps",
"scope": "/BangleApps"
}