ctucx.git: oeffisearch

[nimlang] fast and simple tripplanner

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
'use strict';

const CACHE = 'cache-v34';

let preCache = [
	'./img/product_bus_grey.svg',
	'./img/product_cablecar_color.svg',
	'./img/product_cablecar_grey.svg',
	'./img/product_call_color.svg',
	'./img/product_call_grey.svg',
	'./img/product_ferry_color.svg',
	'./img/product_ferry_grey.svg',
	'./img/product_highspeed_color.svg',
	'./img/product_highspeed_grey.svg',
	'./img/product_suburban_color.svg',
	'./img/product_suburban_grey.svg',
	'./img/product_subway_color.svg',
	'./img/product_subway_grey.svg',
	'./img/product_train_color.svg',
	'./img/product_train_grey.svg',
	'./img/product_bus_color.svg',
	'./img/product_tram_grey.svg',
	'./img/product_tram_color.svg',
	'./img/back.svg',
	'./img/baseline-beenhere-24px.svg',
	'./img/baseline-departure_board-24px.svg',
	'./img/baseline-directions-24px.svg',
	'./img/baseline-directions-24px_white.svg',
	'./img/baseline-directions_walk-24px.svg',
	'./img/baseline-expand_more-24px.svg',
	'./img/baseline-import_export-24px.svg',
	'./img/baseline-navigation-24px.svg',
	'./img/baseline-place-24px.svg',
	'./img/baseline-settings-20px.svg',
	'./ing/baseline-swap_vert-24px.svg',
	'./img/baseline-refresh-24px.svg',
	'./img/ba8064fd767ceaa170589aa3dd11e58e.jpg',
	'./img/favicon-16x16.png',
	'./img/favicon-32x32.png',
	'./img/favicon-64x64.png',
	'./img/favicon-512x512.png',
	'./img/apple-touch-icon.png',
	'./js/api.js',
	'./js/canvas.js',
	'./js/journeysView.js',
	'./js/journeyView.js',
	'./js/searchView.js',
	'./js/settingsView.js',
	'./js/app_functions.js',
	'./js/helpers.js',
	'./js/app.js',
	'./js/router.js',
	'./js/overlays.js',
	'./css/product_selector.css',
	'./css/style.css',
	'./manifest.json',
	'./index.html',
	'./'
];

self.addEventListener('install', function (evt) {
	self.skipWaiting();
	evt.waitUntil(caches.open(CACHE).then(function (cache) {
		cache.addAll(preCache);
	}));
});

self.addEventListener('fetch', function (evt) {
	evt.respondWith(fromCache(evt.request).then(function (match) {
		if (match) {
			return match;
		} else {
			return fetch(evt.request);
		}
	}));
});

self.addEventListener('activate', function (event) {
	event.waitUntil(clients.claim());
	event.waitUntil(clients.claim().then(function () {
		return caches.keys().then(function (cacheNames) {
			return Promise.all(cacheNames.filter(c => c !== CACHE).map(c => caches.delete(c)));
		});
	}));
});

function fromCache (request) {
	return caches.open(CACHE).then(function (cache) {
		return cache.match(request);
	});
}