Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
reflecthub authored Jan 15, 2025
1 parent ca5f0fe commit bb90d66
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
22 changes: 22 additions & 0 deletions manifest.json
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"
}
]
}

64 changes: 64 additions & 0 deletions service-worker.js
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);
}
})
)
)
);
});

0 comments on commit bb90d66

Please sign in to comment.