Commit 94f7b4a2 authored by Yoginth's avatar Yoginth 🦄

Added Service Worker

parent 87d9dcd8
Pipeline #30311689 failed with stages
in 13 minutes and 42 seconds
{
"short_name": "Gitote",
"name": "Gitote - Git with a cup of tea",
"icons": [
{
"src": "fluidicon.png",
"type": "image/png",
"sizes": "880x880"
},
{
"src": "fluidicon.png",
"type": "image/png",
"sizes": "120x120"
}
],
"start_url": "/",
"background_color": "#FAFAFA",
"display": "standalone",
"theme_color": "#000000"
}
\ No newline at end of file
var STATIC_CACHE = 'static-cache-v1';
var urlsToCache = [
// js
'/js/gitote.js',
// css
'/css/gitote.min.css',
'/css/bundle.css',
];
self.addEventListener('install', function (event) {
event.waitUntil(
caches.open(STATIC_CACHE)
.then(function (cache) {
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', function (event) {
event.respondWith(
caches.match(event.request)
.then(function (response) {
if (response) {
return response;
}
return fetch(event.request);
}
)
);
});
\ No newline at end of file
......@@ -62,6 +62,20 @@
<meta name="hostname" content="{{AppURL}}">
<link rel="canonical" href="{{AppURL}}" />
<link rel="manifest" href="/manifest.json">
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/serviceworker.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);
});
});
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.AreYouSure/1.9.0/jquery.are-you-sure.min.js"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment