webapp work, push required for https
This commit is contained in:
parent
8c710e02d1
commit
e58e440a12
|
@ -29,5 +29,3 @@ You can leave it running forever, if you like.
|
||||||
For those interested,
|
For those interested,
|
||||||
it uses the new (in 2017), perfect for this application,
|
it uses the new (in 2017), perfect for this application,
|
||||||
[Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API)
|
[Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API)
|
||||||
|
|
||||||
<button id="install">Add to home screen</button>
|
|
||||||
|
|
|
@ -47,9 +47,7 @@ function init() {
|
||||||
audioCtx.resume();
|
audioCtx.resume();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(navigator.serviceWorker);
|
|
||||||
console.log("moo");
|
|
||||||
if ("serviceWorker" in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
navigator.serviceWorker.register("sw.js");
|
navigator.serviceWorker.register("sw.js");
|
||||||
}
|
}
|
||||||
|
@ -60,24 +58,3 @@ if (document.readyState === "loading") {
|
||||||
} else {
|
} else {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let people add this app
|
|
||||||
let deferredPrompt;
|
|
||||||
let installButton = document.querySelector("#install");
|
|
||||||
installButton.style.display = "none";
|
|
||||||
console.log(installButton);
|
|
||||||
window.addEventListener("beforeinstallprompt", e => {
|
|
||||||
console.log(e);
|
|
||||||
deferredPrompt = e;
|
|
||||||
installButton.style.display = "block";
|
|
||||||
});
|
|
||||||
installButton.addEventListener("click", e => {
|
|
||||||
console.log(e);
|
|
||||||
deferredPrompt.prompt();
|
|
||||||
deferredPrompt.userChoice
|
|
||||||
.then(result => {
|
|
||||||
if (result.output == "accepted") {
|
|
||||||
installButton.style.display = "none";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in New Issue