-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca5f0fe
commit bb90d66
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "ReflectHub", | ||
"short_name": "ReflectHub", | ||
"description": "Read Quran and watch these videos sincerely by reflecting upon them deeply, so that you may find truth and accept it!", | ||
"start_url": "/index.html", | ||
"display": "standalone", | ||
"background_color": "#ffffff", | ||
"theme_color": "#c8ffcd", | ||
"icons": [ | ||
{ | ||
"src": "icon2.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "icon2.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const CACHE_NAME = "abdullah-pwa-cache-v1"; | ||
const ASSETS_TO_CACHE = [ | ||
"/", | ||
"/index.html", | ||
"/index.js", | ||
"/index.css", | ||
"/Logos/Translate.png", | ||
"/Logos/discord.png", | ||
"/Logos/facebook.png", | ||
"/Logos/github.svg", | ||
"/Logos/locate.svg", | ||
"/Logos/reddit.png", | ||
"/Logos/twitter.png", | ||
"/Homepage.png", | ||
"/License.md", | ||
"/README.md", | ||
"/ReflectIMG.png", | ||
"/drop.html", | ||
"/future.html", | ||
"/green.png", | ||
"/hamburger.svg", | ||
"/icon2.png", | ||
"/icon4.png", | ||
"/icon5.png", | ||
"/score.html", | ||
"/search.js" | ||
]; | ||
|
||
// Install Service Worker | ||
self.addEventListener("install", (event) => { | ||
event.waitUntil( | ||
caches.open(CACHE_NAME).then((cache) => { | ||
console.log("Opened cache"); | ||
return cache.addAll(ASSETS_TO_CACHE); | ||
}) | ||
); | ||
}); | ||
|
||
// Fetch Event | ||
self.addEventListener("fetch", (event) => { | ||
event.respondWith( | ||
caches.match(event.request).then((response) => { | ||
// Return cached version or fetch from network | ||
return response || fetch(event.request); | ||
}) | ||
); | ||
}); | ||
|
||
// Activate Service Worker | ||
self.addEventListener("activate", (event) => { | ||
const cacheWhitelist = [CACHE_NAME]; | ||
event.waitUntil( | ||
caches.keys().then((cacheNames) => | ||
Promise.all( | ||
cacheNames.map((cacheName) => { | ||
if (!cacheWhitelist.includes(cacheName)) { | ||
console.log("Deleting old cache:", cacheName); | ||
return caches.delete(cacheName); | ||
} | ||
}) | ||
) | ||
) | ||
); | ||
}); |