-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
240 lines (238 loc) · 9.1 KB
/
sw.js
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/**
* QCObjects SDK 1.0
* ________________
*
* Author: Jean Machuca <[email protected]>
*
* Cross Browser Javascript Framework for MVC Patterns
* QuickCorp/QCObjects is licensed under the
* GNU Lesser General Public License v3.0
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
*
* Permissions of this copyleft license are conditioned on making available
* complete source code of licensed works and modifications under the same
* license or the GNU GPLv3. Copyright and license notices must be preserved.
* Contributors provide an express grant of patent rights. However, a larger
* work using the licensed work through interfaces provided by the licensed
* work may be distributed under different terms and without source code for
* the larger work.
*
* Copyright (C) 2015 Jean Machuca,<[email protected]>
*
* Everyone is permitted to copy and distribute verbatim copies of this
* license document, but changing it is not allowed.
*/
"use strict";
const version = "2.4.0";
const appName = "qcobjects-qr-scanner";
const cacheSufix = (Math.round(Date.now()/(1000*3600))).toString(); // 1 hour
const cacheName = `qcobjects-app-${appName}-${version}-${cacheSufix}`;
const start_url = "/?homescreen=1";
caches.delete(cacheName); // force to reload cache for the first time the sw is loaded
self.addEventListener("install", e => {
e.waitUntil(
caches.open(cacheName).then(cache => {
return cache.addAll([`${start_url}`,
"/",
"LICENSE.txt",
"README.md",
"VERSION",
"css/components/button.css",
"css/components/card.css",
"css/components/hero/hero-call-to-action.css",
"css/components/hero/hero-overlay.css",
"css/components/hero/hero-two-column-form.css",
"css/components/modal.css",
"css/desktop/container.css",
"css/desktop/content.css",
"css/desktop/footer.css",
"css/desktop/index.css",
"css/desktop/navbar.css",
"css/desktop/sidebar.css",
"css/desktop/theme/flutterized/desktop.css",
"css/index.css",
"css/mobile/content.css",
"css/mobile/footer.css",
"css/mobile/index.css",
"css/mobile/navbar.css",
"css/mobile/sidebar.css",
"css/mobile/theme/flutterized/mobile.css",
"css/modern-base.css",
"css/theme/basic/style.css",
"css/theme/cyan/style.css",
"css/theme/flutterized/style.css",
"css/theme/redlight/style.css",
"css/theme/xtra/style.css",
"favicon.ico",
"humans.txt",
"img/Q_web copy.png",
"img/Q_web-white.png",
"img/Q_web.png",
"img/Q_web.svg",
"img/icons/icon-128x128.png",
"img/icons/icon-144x144.png",
"img/icons/icon-152x152.png",
"img/icons/icon-192x192.png",
"img/icons/icon-384x384.png",
"img/icons/icon-512x512.png",
"img/icons/icon-72x72.png",
"img/icons/icon-96x96.png",
"img/logo-qcobjects-version.svg",
"img/logo-qcobjects-white.svg",
"img/logo-qcobjects.svg",
"img/logo.png",
"img/placeholder.svg",
"img/screenshots/screenshot1.png",
"img/screenshots/screenshot1.webp",
"img/screenshots/screenshot2.png",
"img/screenshots/screenshot2.webp",
"index.html",
"js/index.js",
"js/init.js",
"js/packages/installer.js",
"js/packages/org.qcobjects.sdk.controllers.qrscanner.js",
"js/packages/org.qcobjects.services.js",
"js/packages/org.quickcorp.custom.components.js",
"js/packages/org.quickcorp.custom.controllers.js",
"js/packages/org.quickcorp.custom.effects.js",
"js/packages/org.quickcorp.custom.js",
"js/packages/org.quickcorp.custom.models.js",
"js/packages/org.quickcorp.custom.views.js",
"js/packages/thirdparty/libs/qr-scanner/LICENSE",
"js/packages/thirdparty/libs/qr-scanner/README.md",
"js/packages/thirdparty/libs/qr-scanner/qr-scanner-worker.min.js",
"js/packages/thirdparty/libs/qr-scanner/qr-scanner-worker.min.js.map",
"js/packages/thirdparty/libs/qr-scanner/qr-scanner.js",
"js/packages/thirdparty/libs/qr-scanner/qr-scanner.min.js",
"js/packages/thirdparty/libs/qr-scanner/qr-scanner.min.js.map",
"manifest.json",
"package.json",
"res/icon/android/drawable-hdpi-icon.png",
"res/icon/android/drawable-ldpi-icon.png",
"res/icon/android/drawable-mdpi-icon.png",
"res/icon/android/drawable-xhdpi-icon.png",
"res/icon/android/drawable-xxhdpi-icon.png",
"res/icon/android/drawable-xxxhdpi-icon.png",
"res/icon/ios/icon-40.png",
"res/icon/ios/[email protected]",
"res/icon/ios/icon-50.png",
"res/icon/ios/[email protected]",
"res/icon/ios/icon-60.png",
"res/icon/ios/[email protected]",
"res/icon/ios/[email protected]",
"res/icon/ios/icon-72.png",
"res/icon/ios/[email protected]",
"res/icon/ios/icon-76.png",
"res/icon/ios/[email protected]",
"res/icon/ios/icon-small.png",
"res/icon/ios/[email protected]",
"res/icon/ios/[email protected]",
"res/icon/ios/icon.png",
"res/icon/ios/[email protected]",
"res/icon/windows/Square150x150Logo.scale-100.png",
"res/icon/windows/Square150x150Logo.scale-240.png",
"res/icon/windows/Square30x30Logo.scale-100.png",
"res/icon/windows/Square310x310Logo.scale-100.png",
"res/icon/windows/Square44x44Logo.scale-100.png",
"res/icon/windows/Square44x44Logo.scale-240.png",
"res/icon/windows/Square70x70Logo.scale-100.png",
"res/icon/windows/Square71x71Logo.scale-100.png",
"res/icon/windows/Square71x71Logo.scale-240.png",
"res/icon/windows/StoreLogo.scale-100.png",
"res/icon/windows/StoreLogo.scale-240.png",
"res/icon/windows/Wide310x150Logo.scale-100.png",
"res/icon/windows/Wide310x150Logo.scale-240.png",
"res/icon/wp8/ApplicationIcon.png",
"res/icon/wp8/Background.png",
"res/screen/android/drawable-land-hdpi-screen.png",
"res/screen/android/drawable-land-ldpi-screen.png",
"res/screen/android/drawable-land-mdpi-screen.png",
"res/screen/android/drawable-land-xhdpi-screen.png",
"res/screen/android/drawable-land-xxhdpi-screen.png",
"res/screen/android/drawable-land-xxxhdpi-screen.png",
"res/screen/android/drawable-port-hdpi-screen.png",
"res/screen/android/drawable-port-ldpi-screen.png",
"res/screen/android/drawable-port-mdpi-screen.png",
"res/screen/android/drawable-port-xhdpi-screen.png",
"res/screen/android/drawable-port-xxhdpi-screen.png",
"res/screen/android/drawable-port-xxxhdpi-screen.png",
"res/screen/ios/Default-568h@2x~iphone.png",
"res/screen/ios/Default-667h.png",
"res/screen/ios/Default-736h.png",
"res/screen/ios/Default-Landscape-736h.png",
"res/screen/ios/Default-Landscape@2x~ipad.png",
"res/screen/ios/Default-Landscape~ipad.png",
"res/screen/ios/Default-Portrait@2x~ipad.png",
"res/screen/ios/Default-Portrait~ipad.png",
"res/screen/ios/Default@2x~iphone.png",
"res/screen/ios/Default~iphone.png",
"res/screen/windows/SplashScreen.scale-100.png",
"res/screen/windows/SplashScreenPhone.scale-240.png",
"res/screen/wp8/screen-portrait.jpg",
"robots.txt",
"templates/components/article1.tpl.html",
"templates/components/article2.tpl.html",
"templates/components/article3.tpl.html",
"templates/components/article4.tpl.html",
"templates/components/blank.tpl.html",
"templates/components/card.tpl.html",
"templates/components/contentblock.tpl.html",
"templates/components/footer.tpl.html",
"templates/components/footer2.tpl.html",
"templates/components/header.tpl.html",
"templates/components/hero/hero-call-to-action.tpl.html",
"templates/components/hero/hero-overlay.tpl.html",
"templates/components/hero/hero-two-column-form.tpl.html",
"templates/components/install-button.tpl.html",
"templates/components/layout-basic.tpl.html",
"templates/components/loading.tpl.html",
"templates/components/loadingfooter.tpl.html",
"templates/components/login-button.tpl.html",
"templates/components/login.tpl.html",
"templates/components/login2.tpl.html",
"templates/components/loginform.tpl.html",
"templates/components/main.tpl.html",
"templates/components/modal.tpl.html",
"templates/components/nav.tpl.html",
"templates/components/pages/author.tpl.html",
"templates/components/pages/page1.tpl.html",
"templates/components/pages/page2.tpl.html",
"templates/components/pages/page3.tpl.html",
"templates/components/pages/qcobjects-forks-stars.tpl.html",
"templates/components/pages/qcobjects-npm-downloads.tpl.html",
"templates/components/pages/qcobjects.tpl.html",
"templates/components/product.tpl.html",
"templates/components/profile.tpl.html",
"templates/components/pwa.tpl.html",
"templates/components/qrscan.tpl.html",
"templates/components/qrscancode.tpl.html",
"templates/components/section1.tpl.html",
"templates/components/section2.tpl.html",
"templates/components/shadowed-card.tpl.html",
"templates/components/signin-button.tpl.html",
"templates/components/signin.tpl.html",
"templates/components/signup-form.tpl.html",
"templates/components/signup.tpl.html",
"templates/components/signupbuttons.tpl.html",
"templates/components/signupform.tpl.html",
"templates/components/signuppage.tpl.html",
"templates/components/signupsuccessful.tpl.html",
"templates/components/signupsuccessfulfooter.tpl.html",
"templates/components/splashscreen.tpl.html",
"templates/components/topmenu.tpl.html"])
.then(() => self.skipWaiting());
})
);
});
self.addEventListener("activate", event => {
event.waitUntil(self.clients.claim());
});
self.addEventListener("fetch", event => {
event.respondWith(
caches.open(cacheName)
.then(cache => cache.match(event.request, {ignoreSearch: true}))
.then(response => {
return response || fetch(event.request);
})
);
});