Added ability to run app offline and fixed add to home icon

This commit is contained in:
William Brawner 2016-09-17 20:32:24 +00:00
parent 7ee0ff7da0
commit b921a65668
2 changed files with 52 additions and 3 deletions

View file

@ -19,6 +19,7 @@
});
</script>
<title>Interval Timer</title>
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon-180x180.png">
<link rel="apple-touch-icon" sizes="57x57" href="/img/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/img/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/img/apple-touch-icon-72x72.png">
@ -27,14 +28,13 @@
<link rel="apple-touch-icon" sizes="120x120" href="/img/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/img/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/img/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="/img/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/img/favicon-194x194.png" sizes="194x194">
<link rel="icon" type="image/png" href="/img/android-chrome-192x192.png" sizes="192x192">
<link rel="shortcut icon" type="image/png" href="/img/android-chrome-192x192.png" sizes="192x192">
<link rel="icon" type="image/png" href="/img/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/img/manifest.json">
<link rel="mask-icon" href="/img/safari-pinned-tab.svg" color="#ffeb3b">
<link rel="shortcut icon" href="/img/favicon.ico">
<link rel="icon" href="/img/favicon.ico">
<meta name="msapplication-TileColor" content="#ffc40d">
<meta name="msapplication-TileImage" content="/img/mstile-144x144.png">
<meta name="msapplication-config" content="/img/browserconfig.xml">
@ -79,5 +79,12 @@
<a class="form-button" id="save" ng-click="settingsOpen = false; closeSettings = true; time = warmUpTime; resetTimer(); saveTimer()" href="#"> Save Changes</a>
</form>
</div>
<script>
if('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/sw.js')
.then(function() { console.log("Service Worker Registered"); });
}
</script>
</body>
</html>

42
sw.js Normal file
View file

@ -0,0 +1,42 @@
self.addEventListener('install', function(e) {
e.waitUntil(
caches.open('wbrawner-interval-timer').then(function(cache) {
return cache.addAll([
'/',
'/audio/beep-10.mp3',
'/audio/beep-09.mp3',
'/audio/button-42(1).mp3',
'/css/addtohomescreen.css',
'/css/font-awesome.min.css',
'/css/styles.css',
'/fonts/fontawesome-webfont.woff',
'/fonts/FontAwesome.otf',
'/fonts/fontawesome-webfont.svg',
'/fonts/fontawesome-webfont.woff2',
'/fonts/fontawesome-webfont.ttf',
'/fonts/fontawesome-webfont.eot',
'/index.html',
'/js/start.js',
'/js/angular-cookies.min.js',
'/js/addtohomescreen.min.js',
'/js/addtohomescreen.js',
'/js/angular.min.js',
'/js/app.js',
'/sw.js'
]);
})
);
});
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
caches.open('wbrawner-interval-timer').then(function(cache) {
if (event.request.url.match(/^https?/)) {
cache.add(event.request.url);
}
})
return response || fetch(event.request);
})
);
});