diff options
author | altaf-creator <64111012+altaf-creator@users.noreply.github.com> | 2023-05-04 20:27:00 +0700 |
---|---|---|
committer | altaf-creator <64111012+altaf-creator@users.noreply.github.com> | 2023-05-04 20:27:00 +0700 |
commit | 57ef45d288fae81000e1d8669c0ddd68aa27cb63 (patch) | |
tree | d9d0e0da09230308502911ace644e032bfddbe18 /src/scripts | |
parent | 4898f6889e7b4ab39f04c152e17ac4ca763ff975 (diff) |
PWA Update - attempt 4.1 | it doesn't work :(
Diffstat (limited to 'src/scripts')
-rw-r--r-- | src/scripts/main.js | 12 | ||||
-rw-r--r-- | src/scripts/service-worker.js | 13 |
2 files changed, 12 insertions, 13 deletions
diff --git a/src/scripts/main.js b/src/scripts/main.js index e4efee0..091a3d2 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,5 +1,17 @@ +function urlExists(url) { + var http = new XMLHttpRequest(); + http.open('HEAD', url, false); + if (http.status != 200) + console.log(`${http.status} ${url} `) + http.send(); + return http.status != 404; +} + if ("serviceWorker" in navigator) { window.addEventListener("load", function () { + for (var i = 0; i < assets.length; i++) { + urlExists(assets[i]); + } navigator.serviceWorker .register("scripts/service-worker.js") diff --git a/src/scripts/service-worker.js b/src/scripts/service-worker.js index 38cffd5..e6d2a5a 100644 --- a/src/scripts/service-worker.js +++ b/src/scripts/service-worker.js @@ -23,23 +23,10 @@ const assets = [ "../src/scripts/sura-list.js", ]; -function urlExists(url) { - var http = new XMLHttpRequest(); - http.open('HEAD', url, false); - if (http.status != 200) - console.log(url) - http.send(); - return http.status != 404; -} - self.addEventListener("install", installEvent => { installEvent.waitUntil( caches.open(staticQuran).then(cache => { cache.addAll(assets) - for (var i = 0; i < assets.length; i++) { - urlExists(assets[i]); - } - console.log(assets) }) ) }) |