webapp work, push required for https
This commit is contained in:
parent
d0ab88047f
commit
af8375e36c
|
@ -16,6 +16,8 @@ headers:
|
|||
</span>
|
||||
</div>
|
||||
|
||||
<button id="install">Add to home screen</button>
|
||||
|
||||
I work in a building with no HVAC,
|
||||
which means we can hear <em>everything</em> people are saying,
|
||||
anywhere in the building.
|
||||
|
|
|
@ -53,6 +53,23 @@ function init() {
|
|||
if ("serviceWorker" in navigator) {
|
||||
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") {
|
||||
|
|
|
@ -23,4 +23,4 @@ self.addEventListener("fetch", e => {
|
|||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue