diff --git a/icon-192x192.png b/icon-192x192.png new file mode 100644 index 0000000..6d2f3ff Binary files /dev/null and b/icon-192x192.png differ diff --git a/icon-512x512.png b/icon-512x512.png new file mode 100644 index 0000000..0efe2ad Binary files /dev/null and b/icon-512x512.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..ab4a962 --- /dev/null +++ b/manifest.json @@ -0,0 +1,22 @@ +{ + "name": "Research-Nexas", + "short_name": "Research-Nexas", + "start_url": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#000000", + "icons": [ + { + "src": "/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/icon-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ] + + } + diff --git a/public/index.html b/public/index.html index 2167715..cde4121 100644 --- a/public/index.html +++ b/public/index.html @@ -8,6 +8,9 @@ + + + Research Nexas @@ -1097,6 +1100,8 @@

What feature of Research-Nexas do you find most valuable?

+ + \ No newline at end of file diff --git a/public/script/scripts.js b/public/script/scripts.js new file mode 100644 index 0000000..d73ca9a --- /dev/null +++ b/public/script/scripts.js @@ -0,0 +1,14 @@ +// Register the service worker +if ('serviceWorker' in navigator) { + window.addEventListener('load', () => { + navigator.serviceWorker.register('/sw.js') // Pointing to the sw.js file + .then(registration => { + console.log('ServiceWorker registration successful:', registration); + }) + .catch(error => { + console.error('ServiceWorker registration failed:', error); + }); + }); + + +} \ No newline at end of file diff --git a/sw.js b/sw.js new file mode 100644 index 0000000..27846f5 --- /dev/null +++ b/sw.js @@ -0,0 +1,46 @@ +const CACHE_NAME = 'my-pwa-cache-v1'; +const urlsToCache = [ + '/', + '/index.html', + '/styles.css', + '/script/scripts.js', + '/manifest.json', + '/icon-192x192.png', + '/icon-512x512.png' +]; + + +self.addEventListener('install', (event) => { + event.waitUntil( + caches.open(CACHE_NAME) + .then((cache) => { + return cache.addAll(urlsToCache); + }) + ); +}); + + +self.addEventListener('fetch', (event) => { + event.respondWith( + caches.match(event.request) + .then((response) => { + return response || fetch(event.request); + }) + ); +}); + + +self.addEventListener('activate', (event) => { + const cacheWhitelist = [CACHE_NAME]; + event.waitUntil( + caches.keys().then((cacheNames) => { + return Promise.all( + cacheNames.map((cacheName) => { + if (!cacheWhitelist.includes(cacheName)) { + return caches.delete(cacheName); + } + }) + ); + }) + ); +}); \ No newline at end of file