-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
32 lines (28 loc) · 1.11 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const divInstall = document.getElementById("installContainer");
const butInstall = document.getElementById("butInstall");
/* Put code here */
/* Only register a service worker if it's supported */
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/service-worker.js");
}
/**
* Warn the page must be served over HTTPS
* The `beforeinstallprompt` event won't fire if the page is served over HTTP.
* Installability requires a service worker with a fetch event handler, and
* if the page isn't served over HTTPS, the service worker won't load.
*/
if (window.location.protocol === "http:") {
const requireHTTPS = document.getElementById("requireHTTPS");
const link = requireHTTPS.querySelector("a");
link.href = window.location.href.replace("http://", "https://");
requireHTTPS.classList.remove("hidden");
}
/**
* Warn the page must not be served in an iframe.
*/
if (window.self !== window.top) {
const requireTopLevel = document.getElementById("requireTopLevel");
const link = requireTopLevel.querySelector("a");
link.href = window.location.href;
requireTopLevel.classList.remove("hidden");
}