diff --git a/index.html b/index.html index 16ec8963..c5fc499e 100644 --- a/index.html +++ b/index.html @@ -15,6 +15,7 @@ +
@@ -300,6 +301,7 @@ + diff --git a/manifest.json b/manifest.json new file mode 100644 index 00000000..31221964 --- /dev/null +++ b/manifest.json @@ -0,0 +1,21 @@ +{ + "name": "Dataverse", + "short_name": "App", + "start_url": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#000000", + "icons": [ + { + "src": "/software/images/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/software/images/icon-192x192.png", + "sizes": "512x512", + "type": "image/png" + } + ] + } + \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 00000000..4ec7824e --- /dev/null +++ b/script.js @@ -0,0 +1,11 @@ +if ('serviceWorker' in navigator) { + window.addEventListener('load', () => { + navigator.serviceWorker.register('/sw.js') + .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/software/images/icon-192x192.png b/software/images/icon-192x192.png new file mode 100644 index 00000000..601a844a Binary files /dev/null and b/software/images/icon-192x192.png differ diff --git a/software/images/icon-512x512.png b/software/images/icon-512x512.png new file mode 100644 index 00000000..d4b010d5 Binary files /dev/null and b/software/images/icon-512x512.png differ diff --git a/sw.js b/sw.js new file mode 100644 index 00000000..3ccaf443 --- /dev/null +++ b/sw.js @@ -0,0 +1,31 @@ + +const CACHE_NAME = 'my-app-cache-v1'; +const urlsToCache = [ + '/index.html', + '/website/pages/license.html', + '/website/pages/license.html', + '/website/pages/contributor.html', + '/website/styles/style.css', + '/website/styles/contributor.css', + '/script.js', + '/software/images/icon-192x192.png', + '/software/images/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); + }) + ); +});