1"use strict"; 2 3 4window.addEventListener('load', async (event) => { 5 6 const logClick = {}; 7 const logClickSingle = true; 8 9 // TODO refactor the single click vs group logic here. 10 // Listen on all clicks for click logging 11 document.addEventListener('click', function (event) { 12 event.composedPath().forEach(element => { 13 if (element.dataset && element.dataset.logc) { 14 if (logClickSingle) { 15 // Single log per click version. 16 const postData = []; 17 postData.push([element.dataset.logc, "1"]) 18 navigator.sendBeacon('/app/log/', new URLSearchParams(postData)); 19 } else { 20 // Log everything and then submit on visibilitychange option 21 if (!logClick[element.dataset.logc]) { 22 logClick[element.dataset.logc] = 1; 23 } else { 24 logClick[element.dataset.logc] += 1; 25 } 26 } 27 } 28 }); 29 }); 30 31 // Send log on visibilitychange 32 if (!logClickSingle) { 33 document.addEventListener('visibilitychange', function logData() { 34 if (document.visibilityState === 'hidden') { 35 const postData = []; 36 const keys = Object.keys(logClick); 37 keys.forEach((key, index) => { 38 postData.push([key, logClick[key]]); 39 }); 40 navigator.sendBeacon('/app/log/', new URLSearchParams(postData)); 41 } 42 }); 43 } 44});
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.