webapp work, push required for https

This commit is contained in:
Neale Pickett 2018-11-21 22:09:43 +00:00
parent d0ab88047f
commit af8375e36c
3 changed files with 20 additions and 1 deletions

View File

@ -16,6 +16,8 @@ headers:
</span> </span>
</div> </div>
<button id="install">Add to home screen</button>
I work in a building with no HVAC, I work in a building with no HVAC,
which means we can hear <em>everything</em> people are saying, which means we can hear <em>everything</em> people are saying,
anywhere in the building. anywhere in the building.

View File

@ -53,6 +53,23 @@ function init() {
if ("serviceWorker" in navigator) { if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("sw.js"); navigator.serviceWorker.register("sw.js");
} }
// Let people add this app
let installButton = document.querySelector("#install");
installButton.style.display = "none";
window.addEventListener("beforeinstallprompt", e => {
deferredPrompt = e;
installButton.style.display = "block";
});
installButton.addEventListener("click", e => {
deferredPrompt.prompt();
deferredPrompt.userChoice
.then(result => {
if (result.output == "accepted") {
installButton.style.display = "none"
};
});
});
} }
if (document.readyState === "loading") { if (document.readyState === "loading") {