PageSourceSearch

https://chastnik-m.ru/service-worker.js

js chastnik-m.ru collected 2026-10-02 17:49:47 UTC 3,386 bytes, 84 lines download raw bytes

1var CACHE = 'cacheStatic';
2var MAX_AGE = 216000; //86400000;
3
4self.caches.delete('airhorner');
5self.caches.delete('Airhorner');
6
7var cacheUrls = [
8    '/src/css/index.css',
9    '/src/css/global_menu.css',
10    '/src/bootstrap/css/bootstrap.min.css',
11    '/src/bootstrap/fonts/glyphicons-halflings-regular.woff2',
12    '/vendor/components/jqueryui/themes/base/jquery-ui.min.css',
13    '/vendor/components/jqueryui/jquery-ui.min.js',
14    '/vendor/components/jquery/jquery.min.js',
15    '/src/bootstrap/js/bootstrap-datetimepicker.min.js',
16    '/src/bootstrap/js/bootstrap.min.js',
17    '/js/chastnik_new.js',
18    '/src/font-awesome/fonts/fontawesome-webfont.woff',
19    '/fonts/DaysRegular/DaysRegular.woff',
20    '/images/bg/fill/fill.jpg',
21    '/main/no_connect',
22    '/images/market/logo_market.svg'
23];
24
25console.log('sw3');
26
27self.addEventListener('fetch', function(event) {
28    event.respondWith(
29        // ищем запрошенный ресурс в кеше
30        caches.match(event.request).then(function(cachedResponse) {
31            var lastModified, fetchRequest;
32            //проверка присутствия элемента в кеше
33            if (cachedResponse) {
34                // получаем дату последнего обновления элемента
35                lastModified = new Date(cachedResponse.headers.get('last-modified'));
36                // в случае если кеш устарел (сутки) то обновляем его свежими данными
37                if (lastModified && (Date.now() - lastModified.getTime()) > MAX_AGE) {
38
39                    fetchRequest = event.request.clone();
40                    // создаём новый запрос
41                    return fetch(fetchRequest).then(function(response) {
42                        // усли ресурс недоступен, то отдаем результат из кеша
43                        if (!response || response.status !== 200) {
44                            return cachedResponse;
45                        }
46                        // обновляем кэш
47                        caches.open(CACHE_NAME).then(function(cache) {
48                            cache.put(event.request, response.clone());
49                        });
50                        // возвращаем свежий ресурс
51                        return response;
52                    }).catch(function() {
53                        return cachedResponse;
54                    });
55                }
56                return cachedResponse;
57            }
58
59            // запрашиваем из сети как обычно
60            return fetch(event.request);
61        }).catch(() => {
62            return caches.match('/main/no_connect');
63        })
64    );
65});
66
67
68self.addEventListener('notificationclick', function(event) {
69    const target = (event.data.data.click_action || '/');
70    console.log(target);
71    event.notification.close();
72    event.waitUntil(clients.matchAll({
73        type: 'window',
74        includeUncontrolled: true
75    }).then(function(clientList) {
76        for (var i = 0; i < clientList.length; i++) {
77            var client = clientList[i];
78            if (client.url == target && 'focus' in client) {
79                return client.focus();
80            }
81        }
82        return clients.openWindow(target);
83    }));
84});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.