diff --git a/src/main/resources/static/img/icon_192.png b/src/main/resources/static/img/icon_192.png new file mode 100644 index 0000000..94d335d Binary files /dev/null and b/src/main/resources/static/img/icon_192.png differ diff --git a/src/main/resources/static/img/icon_512.png b/src/main/resources/static/img/icon_512.png new file mode 100644 index 0000000..62605a8 Binary files /dev/null and b/src/main/resources/static/img/icon_512.png differ diff --git a/src/main/resources/static/js/workerRegister.js b/src/main/resources/static/js/workerRegister.js new file mode 100644 index 0000000..9907be1 --- /dev/null +++ b/src/main/resources/static/js/workerRegister.js @@ -0,0 +1,11 @@ +if ('serviceWorker' in navigator) { + window.addEventListener('load', function() { + navigator.serviceWorker.register('/sw.js').then(function(registration) { + // Registration was successful + console.log('ServiceWorker registration successful with scope: ', registration.scope); + }, function(err) { + // registration failed :( + console.log('ServiceWorker registration failed: ', err); + }); + }); +} \ No newline at end of file diff --git a/src/main/resources/static/manifest.json b/src/main/resources/static/manifest.json new file mode 100644 index 0000000..9f5c407 --- /dev/null +++ b/src/main/resources/static/manifest.json @@ -0,0 +1,20 @@ +{ + "short_name": "Claptrap", + "name": "Claptrap Bot", + "icons": [ + { + "src": "/img/icon_192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "/img/icon_512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": "/", + "display": "standalone", + "theme_color": "#263238", + "background_color": "#263238" +} \ No newline at end of file diff --git a/src/main/resources/static/sw.js b/src/main/resources/static/sw.js new file mode 100644 index 0000000..f628efe --- /dev/null +++ b/src/main/resources/static/sw.js @@ -0,0 +1,36 @@ + +var CACHE_NAME = 'Clap-Trap-Bot-V1'; +var urlsToCache = [ + '/', + '/music', + '/register', + '/oauthCallback' +]; + + + + +self.addEventListener('install', function(event) { + // Perform install steps + event.waitUntil( + caches.open(CACHE_NAME) + .then(function(cache) { + console.log('Opened cache'); + return cache.addAll(urlsToCache); + }) + ); +}); + +self.addEventListener('fetch', function(event) { + event.respondWith( + caches.match(event.request) + .then(function(response) { + // Cache hit - return response + if (response) { + return response; + } + return fetch(event.request); + } + ) + ); +}); \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 4053048..419cae2 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -12,6 +12,7 @@ + @@ -37,6 +38,7 @@ +
@@ -287,6 +289,8 @@ + +