Add service worker and manifest
This commit is contained in:
parent
d3f9af7d1c
commit
985ad35fca
BIN
src/main/resources/static/img/icon_192.png
Normal file
BIN
src/main/resources/static/img/icon_192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
BIN
src/main/resources/static/img/icon_512.png
Normal file
BIN
src/main/resources/static/img/icon_512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
11
src/main/resources/static/js/workerRegister.js
Normal file
11
src/main/resources/static/js/workerRegister.js
Normal file
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
20
src/main/resources/static/manifest.json
Normal file
20
src/main/resources/static/manifest.json
Normal file
@ -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"
|
||||||
|
}
|
36
src/main/resources/static/sw.js
Normal file
36
src/main/resources/static/sw.js
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
@ -12,6 +12,7 @@
|
|||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
|
||||||
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||||
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||||
|
<link rel="manifest" href="/manifest.json"/>
|
||||||
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
@ -37,6 +38,7 @@
|
|||||||
<script th:src="@{/js/navabar.js}"></script>
|
<script th:src="@{/js/navabar.js}"></script>
|
||||||
<script th:src="@{/js/js.cookie.js}"></script>
|
<script th:src="@{/js/js.cookie.js}"></script>
|
||||||
<script src="https://use.fontawesome.com/releases/v5.3.1/js/all.js" crossorigin="anonymous"></script>
|
<script src="https://use.fontawesome.com/releases/v5.3.1/js/all.js" crossorigin="anonymous"></script>
|
||||||
|
<script th:src="@{/js/workerRegister.js}"></script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
|
||||||
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||||
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||||
|
<link rel="manifest" href="/manifest.json"/>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="blue-grey lighten-5" >
|
<body class="blue-grey lighten-5" >
|
||||||
@ -287,6 +289,8 @@
|
|||||||
<script th:src="@{/js/music.js}"></script>
|
<script th:src="@{/js/music.js}"></script>
|
||||||
<script th:src="@{/js/navabar.js}"></script>
|
<script th:src="@{/js/navabar.js}"></script>
|
||||||
<script th:src="@{/js/js.cookie.js}"></script>
|
<script th:src="@{/js/js.cookie.js}"></script>
|
||||||
|
<script th:src="@{/js/workerRegister.js}"></script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
|
||||||
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||||
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
|
||||||
|
<link rel="manifest" href="/manifest.json"/>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="blue-grey lighten-5" >
|
<body class="blue-grey lighten-5" >
|
||||||
@ -98,6 +99,8 @@
|
|||||||
<script th:src="@{/js/register.js}"></script>
|
<script th:src="@{/js/register.js}"></script>
|
||||||
<script th:src="@{/js/navabar.js}"></script>
|
<script th:src="@{/js/navabar.js}"></script>
|
||||||
<script th:src="@{/js/js.cookie.js}"></script>
|
<script th:src="@{/js/js.cookie.js}"></script>
|
||||||
|
<script th:src="@{/js/workerRegister.js}"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user