-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
24 lines (19 loc) · 843 Bytes
/
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
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');
}