progressive web app

This commit is contained in:
Jonas Weinz 2019-03-10 14:17:31 +01:00
parent 2c46020497
commit 69f8ff2f64
4 changed files with 53 additions and 2 deletions

View File

@ -2,9 +2,9 @@
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="style.css">
<head> <head>
<meta name="viewport" content="width=device-width, user-scalable=no" /> <meta name="viewport" content="width=device-width, user-scalable=no" />
<!-- <link rel="manifest" href="manifest.json" /> --> <link rel="manifest" href="manifest.json" />
<link rel="icon" href="icon.png" type="image/png"/> <link rel="icon" href="icon.png" type="image/png"/>
<!-- <script defer src="site.js"></script> --> <script defer src="site.js"></script>
<title>ultimate tictactoe</title> <title>ultimate tictactoe</title>
</head> </head>
<body> <body>

15
manifest.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "Ultimate TicTacToe",
"short_name": "Ultimate TicTacToe",
"display": "standalone",
"start_url": "/",
"theme_color": "#4650e2",
"background_color": "#1e2477",
"icons": [
{
"src": "icon.png",
"sizes": "192x192",
"type": "image/png"
}
]
}

3
site.js Normal file
View File

@ -0,0 +1,3 @@
navigator.serviceWorker && navigator.serviceWorker.register('./sw.js').then(function(registration) {
console.log('Excellent, registered with scope: ', registration.scope);
});

33
sw.js Normal file
View File

@ -0,0 +1,33 @@
self.addEventListener('install', function(e) {
e.waitUntil(
caches.open('your-magic-cache').then(function(cache) {
return cache.addAll([
'/',
'/index.html',
'/manifest.json',
'/icon.png',
'/LICENSE',
'/main.js',
'/grid.js',
'/game_manager.js',
'/game_server_connection.js',
'/sidebar.js',
'/settings.js',
'/subgrid.js',
'/tile.js',
'/README.md',
'/site.js',
'/style.css',
]);
})
);
});
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});