summaryrefslogtreecommitdiff
path: root/src/scripts/main.js
blob: 96210b1bbaace0a8982f5dca6edfe1d1c5a1346f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function urlExists(url) {
    var http = new XMLHttpRequest();
    http.open('HEAD', url, false);
    http.send();
    console.log(`${http.status} ${url} `)
    return http.status != 404;
}

if ("serviceWorker" in navigator) {
    window.addEventListener("load", function () {
        try {
            process.versions['electron'];
        } catch {
            for (var i = 0; i < assets.length; i++) {
                urlExists(assets[i]);
            }

            navigator.serviceWorker
                .register("scripts/service-worker.js")
                .then(res => console.log("service worker registered"))
                .catch(err => console.log("service worker not registered", err))
        }
    })
}