1var dataCacheName = 'TYPL'; 2var cacheName = 'TYPL.2026.05.27'; 3var filesToCache = [ 4 "/zh-tw/Home/Layout", 5 "/zh-tw/Home/GetVenues", 6 "/en-us/Home/Layout", 7 "/en-us/Home/GetVenues", 8 "/ja/Home/Layout", 9 "/ja/Home/GetVenues", 10 "/ko/Home/Layout", 11 "/ko/Home/GetVenues", 12 "/Kids/Home/Layout", 13 "/Senior/Home/Layout", 14 "/Content/CSS/Bundle", 15 "/Content/CSS/fonts/icomoon.ttf?10si43", 16 "/Content/CSS/Kids", 17 "/Content/CSS/Senior", 18 "/Content/images/banner-fill.png", 19 "/Content/images/default.jpg", 20 "/Content/images/favicon.ico", 21 "/Content/images/footer-fill.png", 22 "/Content/images/footer-fill2.png", 23 "/Content/images/footer-logo.png", 24 "/Content/images/ic_closepage.png", 25 "/Content/images/ic_date.png", 26 "/Content/images/ic_date_active.png", 27 "/Content/images/ic_down-arrow.png", 28 "/Content/images/ic_down-arrow2.png", 29 "/Content/images/ic_download.png", 30 "/Content/images/ic_download2.png", 31 "/Content/images/ic_fb-s.png", 32 "/Content/images/ic_line.png", 33 "/Content/images/ic_link.png", 34 "/Content/images/ic_list.png", 35 "/Content/images/ic_list_active.png", 36 "/Content/images/ic_nav-info.png", 37 "/Content/images/ic_nav-login.png", 38 "/Content/images/ic_nav-login_xmas.png", 39 "/Content/images/ic_nav-search.png", 40 "/Content/images/ic_printer.png", 41 "/Content/images/ic_search.png", 42 "/Content/images/logo.png", 43 "/Content/images/QR_Android.png", 44 "/Content/images/QR_Android_Kids.png", 45 "/Content/images/QR_iOS.png", 46 "/Content/images/QR_iOS_Kids.png", 47 "/Content/images/QR_LINE.png", 48 "/Content/images/QR_LINE_Kids.png", 49 "/Content/images/side-fb.png", 50 "/Content/images/side-top.png", 51 "/Content/images/side-youtube.png", 52 "/Content/JS/Bundle", 53 "/Content/JS/Custom", 54]; 55 56self.addEventListener('install', event => { 57 event.waitUntil( 58 caches.open(cacheName).then(cache => { 59 console.log('[SW]install:', cacheName); 60 return cache.addAll(filesToCache).then(() => { 61 console.log('[SW]installed:', cacheName); 62 self.skipWaiting(); 63 caches.keys().then(keyList => { 64 if (keyList.length > 1) 65 self.clients.matchAll({ includeUncontrolled: true, type: 'window' }).then(clients => 66 clients.forEach(client => client.postMessage({ msg: "SW:Update" }))); 67 }); 68 }); 69 }) 70 ); 71}); 72 73self.addEventListener('activate', function (e) { 74 e.waitUntil( 75 caches.keys().then(function (keyList) { 76 return Promise.all(keyList.map(function (key) { 77 if (key !== cacheName && key !== dataCacheName) { 78 console.log('[SW]delete:', key); 79 return caches.delete(key); 80 } 81 })); 82 }) 83 ); 84 return self.clients.claim(); 85}); 86 87self.addEventListener('fetch', function (e) { 88 let xhr = e.request.headers.get("X-Requested-With"); 89 let url = getLocation(e.request.url); 90 if (!url) return; 91 let path = url.pathname; 92 var request = e.request; 93 if (url.host === location.host && 94 xhr != "SW" && 95 !['.', '/Home/GetVenues', '/RSS/', '/Files'].some(s => path.includes(s)) && 96 !['/', '/Questionnaire', '/Content'].some(s => url.language === s)) //ç¶²é æ¡æ¶ 97 { 98 request = new Request(url.protocol + "//" + url.host + url.language + "/Home/Layout"); 99 url = getLocation(request.url); 100 path = url.pathname; 101 } 102 //console.log("request", request) 103 e.respondWith( 104 caches.match(request, { ignoreVary: true }) 105 .then(function (response) { 106 try { 107 function cache() { 108 return fetch(request, { cache: 'no-cache' }).then(response => { 109 if (response.status === 404 && (path.indexOf("/Content/") === 0 || path.indexOf("/FileUploads/") === 0)) 110 return fetch("/Content/images/default.jpg"); 111 if (response && 112 request.method === 'GET' && 113 request.url == response.url && 114 response.status === 200 && 115 response.type === 'basic' && 116 url.host === location.host && 117 (path.includes(".") || path.includes("/Home/")) && 118 !path.includes(".json") && 119 !path.includes("/FileUploads/") && 120 !path.includes("/BotDetectCaptcha.ashx")) { 121 var responseToCache = response.clone(); 122 caches.open(cacheName) 123 .then(cache => { 124 cache.put(request, responseToCache); 125 //console.log('[SW]cache ', path); 126 }); 127 } 128 return response; 129 }); 130 } 131 132 if (response && request.method != 'POST') { //ç¶²é å¿«å 133 setTimeout(cache, 5000); 134 //console.log('[SW]use ', e.request.url); 135 return response; 136 } 137 138 return cache(); 139 } 140 catch (err) { 141 console.log('[SW]error ', path); 142 } 143 }) 144 ); 145}); 146 147function getLocation(href) { 148 var match = href.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/Page)?(([\/]{0,1}[^?#\/]*)([\/]{0,1}[^?#\/]*)([\/]{0,1}[^?#\/]*)([\/]{0,1}[^?#]*))(\?[^#]*|)(#.*|)$/); 149 return match && { 150 href: href, 151 protocol: match[1], 152 host: match[2], 153 hostname: match[3], 154 port: match[4], 155 page: match[5], 156 pathname: match[6], 157 language: match[7], 158 controller: match[8], 159 action: match[9], 160 searchid: match[10], 161 search: match[11], 162 hash: match[12] 163 } 164}
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.