This repository was archived by the owner on Oct 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathServiceWorker.js
More file actions
67 lines (57 loc) · 1.9 KB
/
ServiceWorker.js
File metadata and controls
67 lines (57 loc) · 1.9 KB
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
/*
Coding to Learn and Create
Copyright 2019 OCAD University
Licensed under the 3-Clause BSD license. You may not use this file except in compliance with this license.
You may obtain a copy of the 3-Clause BSD License at
https://github.com/simonbates/c2lc-exploratory/raw/master/LICENSE.txt
*/
/* eslint-env es6 */
(function () {
"use strict";
const CACHE_NAME = "c2lc-exploratory-v1";
const FILES_TO_CACHE = [
"c2lc.css",
"icons/icon-192x192.png",
"icons/icon-512x512.png",
"index.html",
"manifest.json",
"node_modules/infusion/dist/infusion-all.js",
"src/App.js",
"src/BluetoothDevice.js",
"src/BluetoothDeviceActionHandler.js",
"src/DashDriver.js",
"src/DeviceConnectControl.js",
"src/FeatureDetection.js",
"src/Interpreter.js",
"src/InterpreterControls.js",
"src/Math.js",
"src/ProgramBlockEditor.js",
"src/ProgramTextEditor.js",
"src/ProgramUtils.js",
"src/SpheroDriver.js",
"src/SpheroPacketBuilder.js",
"src/SpheroTurtle.js",
"src/TextSyntax.js",
"src/TurtleGraphics.js"
];
self.addEventListener("install", function (e) {
e.waitUntil(
caches.open(CACHE_NAME).then(function (cache) {
return cache.addAll(FILES_TO_CACHE);
})
);
});
self.addEventListener("fetch", function (e) {
e.respondWith(
caches.open(CACHE_NAME).then(function (cache) {
return cache.match(e.request).then(function (response) {
return response || fetch(e.request).then(function (response) {
console.log("Cache miss, fetch from network: "
+ e.request.url);
return response;
});
});
})
);
});
})();