1(function () { 2 'use strict'; 3 4 function boot() { 5 try { 6 var cfg = window.n2sEventBarCfg || {}; 7 var town = ''; 8 var now = new Date(); 9 var minutes = now.getHours() * 60 + now.getMinutes(); 10 11 if (!cfg.townEventsUrl || (cfg.mode !== 'core' && cfg.mode !== 'shadow') || !window.fetch) { 12 return; 13 } 14 try { 15 town = window.localStorage.getItem('n2gomi_town') || ''; 16 } catch (e) { 17 return; 18 } 19 if (!town || minutes < 360 || minutes > 1260) { 20 return; 21 } 22 23 var yyyy = String(now.getFullYear()); 24 var mm = String(now.getMonth() + 1); 25 var dd = String(now.getDate()); 26 var today = yyyy + '-' + (mm.length < 2 ? '0' + mm : mm) + '-' + (dd.length < 2 ? '0' + dd : dd); 27 var cacheKey = 'n2s_event_town_bar'; 28 var cached = null; 29 30 try { 31 cached = JSON.parse(window.localStorage.getItem(cacheKey) || 'null'); 32 } catch (e2) { 33 cached = null; 34 } 35 36 function save(items) { 37 try { 38 window.localStorage.setItem(cacheKey, JSON.stringify({ d: today, t: Date.now(), items: items })); 39 } catch (e3) { 40 // localStorage ã使ããªãã¦ã表示å¦çã¯ç¶ããã 41 } 42 } 43 44 function emit(items) { 45 try { 46 if (!items || !items.length || !window.n2InfoBar || typeof window.n2InfoBar.register !== 'function') { 47 return; 48 } 49 var active = []; 50 var i; 51 for (i = 0; i < items.length; i++) { 52 var time = String(items[i].time || ''); 53 var match = /^(\d{2}):(\d{2})/.exec(time); 54 if (match && ((parseInt(match[1], 10) * 60 + parseInt(match[2], 10)) < minutes)) { 55 continue; 56 } 57 active.push(items[i]); 58 } 59 if (!active.length) { 60 return; 61 } 62 63 var first = active[0]; 64 var title = String(first.title || '').slice(0, 30); 65 var venue = String(first.venue_name || '').slice(0, 15); 66 var text = (cfg.mode === 'shadow' ? 'ããã¬ãã¥ã¼ã' : '') + '仿¥ã¯çºå ã§' + title; 67 if (venue) { 68 text += 'ï¼ ' + venue; 69 } 70 if (active.length > 1) { 71 text += 'ï¼ã»ã' + (active.length - 1) + 'ä»¶ï¼'; 72 } 73 window.n2InfoBar.register({ 74 id: 'event:town:' + today.replace(/-/g, '') + ':' + active.length, 75 source: 'info', 76 icon: 'â©', 77 priority: 68, 78 text: text, 79 url: active.length === 1 && first.url ? String(first.url) : '' 80 }); 81 } catch (e4) { 82 // ãç¥ãããã¼å ¨ä½ã¸ä¾å¤ãæ¼ãããªãã 83 } 84 } 85 86 if (cached && cached.d === today && typeof cached.t === 'number' && Date.now() - cached.t < 1800000 && Array.isArray(cached.items)) { 87 emit(cached.items); 88 return; 89 } 90 91 window.fetch(cfg.townEventsUrl + '?context=matsuri_today', { 92 credentials: 'same-origin', 93 headers: { Accept: 'application/json' } 94 }).then(function (response) { 95 if (!response.ok) { 96 throw new Error('event bar request failed'); 97 } 98 return response.json(); 99 }).then(function (data) { 100 var items = data && Array.isArray(data.items) ? data.items : []; 101 save(items); 102 if (!data || data.need_registration || !items.length) { 103 return; 104 } 105 emit(items); 106 }).catch(function () { 107 // é信失æã¯çºå ã¤ãã³ãã®ã¹ã©ã¤ãã ãã諦ããã 108 }); 109 } catch (e) { 110 // åæå失æãä»ã®ããã³ãå¦çã¸æ³¢åãããªãã 111 } 112 } 113 114 if (document.readyState === 'loading') { 115 document.addEventListener('DOMContentLoaded', boot); 116 } else { 117 boot(); 118 } 119}());
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.