summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraltaf-creator <64111012+altaf-creator@users.noreply.github.com>2023-05-04 19:57:39 +0700
committeraltaf-creator <64111012+altaf-creator@users.noreply.github.com>2023-05-04 19:57:39 +0700
commit04f941b9fb332103a8b3653a480b567577b421e0 (patch)
treea49b8b2da28ba8dc4fb9b8c8a750d8dbbe33438d
parent320c4dbbf120e94649d516953857efd7ce9ce9a1 (diff)
PWA Update - attempt 4 (i hope it works)
-rw-r--r--src/scripts/main.js38
-rw-r--r--src/scripts/service-worker.js6
2 files changed, 3 insertions, 41 deletions
diff --git a/src/scripts/main.js b/src/scripts/main.js
index 4e20f40..e4efee0 100644
--- a/src/scripts/main.js
+++ b/src/scripts/main.js
@@ -1,44 +1,6 @@
-const assets = [
- "../../",
- "../../index.html",
- "../src/index.html",
- "../src/sura.html",
- "../src/attribution.html",
- "../src/styles/style.css",
- "../src/styles/css/fontawesome.css",
- "../src/styles/css/brands.css",
- "../src/styles/css/solid.css",
- "../src/styles/webfonts/fa-brands-400.ttf",
- "../src/styles/webfonts/fa-brands-400.woff2",
- "../src/styles/webfonts/fa-solid-900.ttf",
- "../src/styles/webfonts/fa-solid-900.woff2",
- "../src/styles/css/solid.css",
- "../src/data/en.sahih.xml",
- "../src/data/id.indonesian.xml",
- "../src/data/quran-data.xml",
- "../src/data/quran-uthmani.xml",
- "../src/scripts/main.js",
- "../src/scripts/quran.js",
- "../src/scripts/sura-list.js",
-];
-
-function urlExists(url) {
- var http = new XMLHttpRequest();
- http.open('HEAD', url, false);
- http.send();
-
- if (http.status != 200)
- console.log(url)
-
- 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")
.then(res => console.log("service worker registered"))
diff --git a/src/scripts/service-worker.js b/src/scripts/service-worker.js
index 6e8f8db..e2c291c 100644
--- a/src/scripts/service-worker.js
+++ b/src/scripts/service-worker.js
@@ -18,9 +18,9 @@ const assets = [
"../src/data/id.indonesian.xml",
"../src/data/quran-data.xml",
"../src/data/quran-uthmani.xml",
- "main.js",
- "quran.js",
- "sura-list.js",
+ "../src/scripts/main.js",
+ "../src/scripts/quran.js",
+ "../src/scripts/sura-list.js",
];
self.addEventListener("install", installEvent => {