app manifest

This commit is contained in:
TLRZ Seyfferth 2018-01-14 17:31:17 +01:00
parent f45258cebd
commit 65bd645dd9
3 changed files with 85 additions and 0 deletions

View File

@ -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">
<!--Import materialize.css--> <!--Import materialize.css-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-alpha.3/css/materialize.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-alpha.3/css/materialize.min.css">
<link rel="manifest" href="manifest.json">
</head> </head>
<body> <body>
@ -169,6 +170,16 @@
<script src="js/vue.js"></script> <script src="js/vue.js"></script>
<script src="js/model/article.js"></script> <script src="js/model/article.js"></script>
<script src="js/model/inventory_article.js"></script> <script src="js/model/inventory_article.js"></script>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('serviceWorker.js')
.then(function(registration) {
console.log("[ServiceWorker] registration successful with scope: ", registration.scope);
}).catch(function(err){
console.error("[ServiceWorker] registration failed: ", err);
})
}
</script>
</body> </body>
</html> </html>

25
manifest.json Normal file
View File

@ -0,0 +1,25 @@
{
"manifest_version": 1,
"name": "chrosey.de Inventur",
"version": "1.0",
"default_locale": "de",
"description": "Inventur-Helfer",
"short_name" : "1894. Inventur",
"start_url": "https://chrosey.de/apps/inv",
"icons": [
{
"src": "/favicons/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/favicons/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#303F9F",
"background_color": "#C5CAE9",
"display": "standalone"
}

49
serviceWorker.js Normal file
View File

@ -0,0 +1,49 @@
var CACHE_NAME = "inventur_cache-v1";
var urlsToCache = [
'.',
'js/app.js',
'js/vue.js',
'js/accounting.min.js',
'js/moment-with-locales.min.js',
'js/model/article.js',
'js/model/inventory_article.js'
];
self.addEventListener('install', function(event){
event.waitUntil(
caches.open(CACHE_NAME)
.then(function(cache){
console.log("Cache opened");
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', function(event){
event.respondWith(
caches.match(event.request)
.then(function(response){
if (response) {
return response;
}
var fetchRequest = event.request.clone();
return fetch(fetchRequest).then(
function(response){
if(!response || response.status !== 200 || response.type !== 'basic') {
return response;
}
var responseToCache = response.clone();
caches.open(CACHE_NAME)
.then(function(cache){
cache.put(event.request, responseToCache);
});
return response;
}
)
})
);
});