Bintang Fajar Julio commited on
Commit
b0cc3ff
1 Parent(s): 5518c61
static/manifest.json CHANGED
@@ -2,16 +2,14 @@
2
  "name": "Skripsi JTIK",
3
  "short_name": "SkripsiJTIK",
4
  "start_url": "/",
 
5
  "background_color": "#ffffff",
6
- "description": "Web App for Skripsi JTIK PNJ",
7
- "display": "fullscreen",
8
  "theme_color": "#0f8a9a",
9
  "icons": [
10
  {
11
  "src": "/static/images/favicon.png",
12
- "sizes": "512x512",
13
  "type": "image/png",
14
- "purpose": "any maskable"
15
  }
16
  ]
17
  }
 
2
  "name": "Skripsi JTIK",
3
  "short_name": "SkripsiJTIK",
4
  "start_url": "/",
5
+ "display": "standalone",
6
  "background_color": "#ffffff",
 
 
7
  "theme_color": "#0f8a9a",
8
  "icons": [
9
  {
10
  "src": "/static/images/favicon.png",
 
11
  "type": "image/png",
12
+ "sizes": "192x192"
13
  }
14
  ]
15
  }
static/offline.html DELETED
@@ -1,46 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
-
8
- <title>Offline</title>
9
-
10
- <link rel="shortcut icon" href="/static/images/favicon.png" />
11
- <script defer src="/static/plugins/fontawesome/js/all.min.js"></script>
12
- <link id="theme-style" rel="stylesheet" href="/static/css/portal.css" />
13
- </head>
14
-
15
- <body class="app app-404-page">
16
- <div class="container mb-5">
17
- <div class="row">
18
- <div class="col-12 col-md-11 col-lg-7 col-xl-6 mx-auto">
19
- <div class="app-card p-5 text-center shadow-sm mt-5">
20
- <div
21
- class="app-branding text-center mb-4"
22
- style="margin-bottom: 0px; padding-top: 0px"
23
- >
24
- <a class="app-logo" href=""
25
- ><img
26
- class="logo-icon"
27
- src="/static/images/logotik.png"
28
- alt="logo"
29
- />
30
- </a>
31
- </div>
32
- <h1 class="page-title mb-4">
33
- Network Error<br /><span class="font-weight-light"
34
- >Periksa koneksi internet anda.</span
35
- >
36
- </h1>
37
- <div class="mb-4">Halaman yang anda cari tidak dapat diakses.</div>
38
- </div>
39
- </div>
40
- <!--//col-->
41
- </div>
42
- <!--//row-->
43
- </div>
44
- <!--//container-->
45
- </body>
46
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static/service-worker.js CHANGED
@@ -1,53 +1,39 @@
1
- const preLoad = async function () {
2
- const cache = await caches.open("offline");
3
- return await cache.addAll(filesToCache);
4
- };
5
 
6
- self.addEventListener("install", function (event) {
7
- event.waitUntil(preLoad());
 
 
 
 
 
 
 
 
 
 
8
  });
9
 
10
- const filesToCache = ["/", "/static/offline.html"];
11
-
12
- const checkResponse = function (request) {
13
- return new Promise(function (fulfill, reject) {
14
- fetch(request).then(function (response) {
15
- if (response.status !== 404) {
16
- fulfill(response);
17
- } else {
18
- reject();
19
- }
20
- }, reject);
21
- });
22
- };
23
-
24
- const addToCache = async function (request) {
25
- if (request.url.startsWith("chrome-extension://")) {
26
- return Promise.resolve();
27
- }
28
-
29
- const cache = await caches.open("offline");
30
- const response = await fetch(request);
31
- return await cache.put(request, response);
32
- };
33
-
34
- const returnFromCache = async function (request) {
35
- const cache = await caches.open("offline");
36
- const matching = await cache.match(request);
37
- if (!matching || matching.status === 404) {
38
- return cache.match("offline.html");
39
- } else {
40
- return matching;
41
- }
42
- };
43
 
44
- self.addEventListener("fetch", function (event) {
45
  event.respondWith(
46
- checkResponse(event.request).catch(function () {
47
- return returnFromCache(event.request);
48
  })
49
  );
50
- if (!event.request.url.startsWith("http")) {
51
- event.waitUntil(addToCache(event.request));
52
- }
53
  });
 
1
+ const CACHE_NAME = "my-cache-v1";
 
 
 
2
 
3
+ self.addEventListener("install", (event) => {
4
+ event.waitUntil(
5
+ caches.open(CACHE_NAME).then((cache) => {
6
+ return cache.addAll([
7
+ "/",
8
+ "/static/css/portal.css",
9
+ "/static/js/app.js",
10
+ "/static/images/favicon.png",
11
+ ]);
12
+ })
13
+ );
14
+ self.skipWaiting();
15
  });
16
 
17
+ self.addEventListener("activate", (event) => {
18
+ const cacheWhitelist = [CACHE_NAME];
19
+ event.waitUntil(
20
+ caches.keys().then((cacheNames) => {
21
+ return Promise.all(
22
+ cacheNames.map((cacheName) => {
23
+ if (!cacheWhitelist.includes(cacheName)) {
24
+ return caches.delete(cacheName);
25
+ }
26
+ })
27
+ );
28
+ })
29
+ );
30
+ self.clients.claim();
31
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
+ self.addEventListener("fetch", (event) => {
34
  event.respondWith(
35
+ caches.match(event.request).then((response) => {
36
+ return response || fetch(event.request);
37
  })
38
  );
 
 
 
39
  });