summaryrefslogtreecommitdiffstats
path: root/sw.js
blob: 94a174e833aa921f920484f364b22e22087d0479 (plain) (blame)
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
const static_cache_name = "site-static-v1";
// Got them with du -a and minor cleaning up
const assets = [
    "/",
    "/index.html",
    "/login.html",
    "/favicon.png",

    "/img/icons/icon_144.png",
    "/img/icons/icon_192.png",
    "/img/icons/icon_72.png",
    "/img/icons/icon_384.png",
    "/img/icons/icon_48.png",
    "/img/icons/icon_96.png",
    "/img/icons/icon_512.png",

    "/pages/absences.html",
    "/pages/gradings.html",
    "/pages/grades.html",
    "/pages/teachers.html",
    "/pages/timetable.html",

    "/css/fullcalendar/custom.css",
    "/css/fullcalendar/daygrid/main.min.css",
    "/css/fullcalendar/timegrid/main.min.css",
    "/css/fullcalendar/core/main.min.css",
    "/css/styles.css",
    "/css/materialicons.css",
    "/css/materialize.min.css",

    "/js/gradings.js",
    "/js/login.js",
    "/js/teachers.js",
    "/js/initialize.js",
    "/js/timetable.js",
    "/js/app.js",
    "/js/grades.js",
    "/js/absences.js",

    "/js/lib/materialize.min.js",
    "/js/lib/fullcalendar/daygrid/main.min.js",
    "/js/lib/fullcalendar/timegrid/main.min.js",
    "/js/lib/fullcalendar/core/main.min.js",
    "/js/lib/localforage.min.js",
    "/js/lib/jquery.min.js"
];

importScripts("/js/lib/localforage.min.js");

self.addEventListener("install", (evt) => {
    // Add localforage.clear() if storage purge is required
    evt.waitUntil(
        localforage.clear()
    );

    evt.waitUntil(
        caches.open(static_cache_name).then((cache) => {
            cache.addAll(assets);
        })
    );
});

self.addEventListener("activate", evt => {

})

self.addEventListener("fetch", (evt) => {

});