summaryrefslogtreecommitdiff
path: root/src/scripts
diff options
context:
space:
mode:
authoraltaf-creator <64111012+altaf-creator@users.noreply.github.com>2023-05-04 19:38:08 +0700
committeraltaf-creator <64111012+altaf-creator@users.noreply.github.com>2023-05-04 19:38:08 +0700
commitab7e58067573d02b645c8715d2a923d6b9e02cb3 (patch)
tree04e36f8ef80dd4b2d2b97776141ecf2042d6efb0 /src/scripts
parenta00ba0106f4fe3a17ed39e574e3be89d3d3cc560 (diff)
PWA Update - attempt 3
Diffstat (limited to 'src/scripts')
-rw-r--r--src/scripts/main.js37
-rw-r--r--src/scripts/service-worker.js2
2 files changed, 38 insertions, 1 deletions
diff --git a/src/scripts/main.js b/src/scripts/main.js
index e4efee0..fa738a5 100644
--- a/src/scripts/main.js
+++ b/src/scripts/main.js
@@ -1,6 +1,43 @@
+
+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) {
+ console.log(url);
+ var http = new XMLHttpRequest();
+ http.open('HEAD', url, false);
+ http.send();
+ console.log(http.status)
+ 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 7b34e7b..22d8452 100644
--- a/src/scripts/service-worker.js
+++ b/src/scripts/service-worker.js
@@ -1,5 +1,6 @@
const staticQuran = "quran-all";
const assets = [
+ "/",
"/index.html",
"/src/index.html",
"/src/sura.html",
@@ -21,7 +22,6 @@ const assets = [
"/src/scripts/quran.js",
"/src/scripts/sura-list.js",
];
-
self.addEventListener("install", installEvent => {
installEvent.waitUntil(
caches.open(staticQuran).then(cache => {