made it a progressive web app

This commit is contained in:
Jonas Weinz 2019-02-26 14:45:06 +01:00
parent 414a24ed17
commit 79abc853f8
5 changed files with 52 additions and 3 deletions

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -1,11 +1,13 @@
<html> <html>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="style.css">
<head> <head>
<title>Simon Says</title> <meta name="viewport" content="width=device-width, user-scalable=no" />
<link rel="manifest" href="manifest.json" />
<link rel="icon" href="icon.png" type="image/png"/>
<script defer src="site.js"></script>
<title>Patterns</title>
</head> </head>
<body> <body>
<!-- <canvas id="myCanvas"></canvas> -->
<div id="main-container" class="main-container"> <div id="main-container" class="main-container">
<div id="sidebar-container" class="sidebar-container"> <div id="sidebar-container" class="sidebar-container">
<div id="control-container" class="control-container"></div> <div id="control-container" class="control-container"></div>

15
manifest.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "Patterns",
"short_name": "Patterns",
"display": "minimal-ui",
"start_url": "/",
"theme_color": "#422B42",
"background_color": "#272227",
"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);
});

29
sw.js Normal file
View File

@ -0,0 +1,29 @@
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',
'/sidebar.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);
})
);
});