2019-03-10 14:17:31 +01:00
|
|
|
|
|
|
|
self.addEventListener('install', function(e) {
|
|
|
|
e.waitUntil(
|
|
|
|
caches.open('your-magic-cache').then(function(cache) {
|
|
|
|
return cache.addAll([
|
2019-03-10 15:51:08 +01:00
|
|
|
'/website/ultimate_tictactoe/',
|
|
|
|
'/website/ultimate_tictactoe/index.html',
|
|
|
|
'/website/ultimate_tictactoe/manifest.json',
|
|
|
|
'/website/ultimate_tictactoe/icon.png',
|
|
|
|
'/website/ultimate_tictactoe/LICENSE',
|
|
|
|
'/website/ultimate_tictactoe/main.js',
|
|
|
|
'/website/ultimate_tictactoe/grid.js',
|
2019-03-21 12:35:50 +01:00
|
|
|
'/website/ultimate_tictactoe/local_match_manager.js',
|
|
|
|
'/website/ultimate_tictactoe/online_match_manager.js',
|
|
|
|
'/website/ultimate_tictactoe/websocket_connection.js',
|
|
|
|
'/website/ultimate_tictactoe/infobar.js',
|
|
|
|
'/website/ultimate_tictactoe/infocontainer.js',
|
2019-03-10 15:51:08 +01:00
|
|
|
'/website/ultimate_tictactoe/settings.js',
|
|
|
|
'/website/ultimate_tictactoe/subgrid.js',
|
|
|
|
'/website/ultimate_tictactoe/tile.js',
|
|
|
|
'/website/ultimate_tictactoe/README.md',
|
|
|
|
'/website/ultimate_tictactoe/site.js',
|
|
|
|
'/website/ultimate_tictactoe/style.css',
|
2019-03-10 14:17:31 +01:00
|
|
|
]);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener('fetch', function(event) {
|
|
|
|
event.respondWith(
|
|
|
|
caches.match(event.request).then(function(response) {
|
|
|
|
return response || fetch(event.request);
|
|
|
|
})
|
|
|
|
);
|
2019-03-21 15:41:38 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener('notificationclick', function(event) {
|
|
|
|
event.waitUntil(async function() {
|
|
|
|
const allClients = await clients.matchAll({
|
|
|
|
includeUncontrolled: true
|
|
|
|
});
|
|
|
|
|
|
|
|
var instance = None;
|
|
|
|
|
|
|
|
|
|
|
|
// Let's see if we already have a window open:
|
|
|
|
for (const client of allClients) {
|
|
|
|
client.focus();
|
|
|
|
instance = client;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we didn't find an existing window,
|
|
|
|
// open a new one:
|
|
|
|
if (!instance) {
|
|
|
|
instance = await clients.openWindow(rel_home);
|
|
|
|
}
|
|
|
|
}());
|
2019-03-10 14:17:31 +01:00
|
|
|
});
|