1/** 2 * íì´ì§ ë ¸ì¶ ì¶ì ì¤í¬ë¦½í¸ 3 * - íì´ì§ ë¡ë ì ìëì¼ë¡ ë ¸ì¶ ê¸°ë¡ 4 * - Beacon API ì°ì ì¬ì© (íì´ì§ ì´í ììë íì¤í ì ì¡) 5 * - í´ë°±ì¼ë¡ ì´ë¯¸ì§ í½ì ì¬ì© 6 */ 7(function() { 8 'use strict'; 9 10 // ì¤ì 11 var config = { 12 endpoint: '/track/pv', 13 pageId: null, 14 pageType: 'post', 15 debug: false 16 }; 17 18 // íì´ì§ ë°ì´í° ìì±ìì ì¤ì ì½ê¸° 19 function init() { 20 var tracker = document.querySelector('[data-impression-tracker]'); 21 if (!tracker) { 22 // ëì: bodyìì data ìì± ì°¾ê¸° 23 tracker = document.body; 24 } 25 26 if (tracker) { 27 config.pageId = tracker.dataset.pageId || tracker.dataset.postId; 28 config.pageType = tracker.dataset.pageType || 'post'; 29 } 30 31 // URLìì post ID ì¶ì¶ ìë (/post/123 íí) 32 if (!config.pageId) { 33 var match = window.location.pathname.match(/\/post\/(\d+)/); 34 if (match) { 35 config.pageId = match[1]; 36 } 37 } 38 39 if (config.pageId) { 40 trackImpression(); 41 } else if (config.debug) { 42 console.log('[ImpressionTracker] No page ID found'); 43 } 44 } 45 46 // ë ¸ì¶ ì¶ì ì¤í 47 function trackImpression() { 48 var data = { 49 page_id: config.pageId, 50 page_type: config.pageType 51 }; 52 53 // Beacon API ì¬ì© (ê¶ì¥) 54 if (navigator.sendBeacon) { 55 var formData = new FormData(); 56 formData.append('page_id', data.page_id); 57 formData.append('page_type', data.page_type); 58 59 var success = navigator.sendBeacon(config.endpoint, formData); 60 if (config.debug) { 61 console.log('[ImpressionTracker] Beacon sent:', success, data); 62 } 63 } else { 64 // í´ë°±: ì´ë¯¸ì§ í½ì 65 var img = new Image(1, 1); 66 img.src = config.endpoint + '?p=' + encodeURIComponent(data.page_id) + 67 '&t=' + encodeURIComponent(data.page_type) + 68 '&_=' + Date.now(); 69 if (config.debug) { 70 console.log('[ImpressionTracker] Pixel sent:', data); 71 } 72 } 73 } 74 75 // DOM ë¡ë í ì¤í 76 if (document.readyState === 'loading') { 77 document.addEventListener('DOMContentLoaded', init); 78 } else { 79 init(); 80 } 81})();
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.