1// This code originated in the Track The Click wordpress plugin 2 3(function ($) { 4 window.cachebreak = 1; 5 console.log("RIA Track Click loaded"); 6 function getAnchor(element, textOnly = false) { 7 var anchor = element.innerText; 8 if (anchor.length == 0 && textOnly == false) { 9 anchor = element.innerHTML.trim(); 10 if (typeof element.children !== "undefined") { 11 if (element.children.length > 0) { 12 if (element.children[0].tagName == "IMG") { 13 anchor = "image:" + element.children[0].src; 14 } 15 } 16 } 17 } 18 return anchor; 19 } 20 function bubbleBeacon(event) { 21 if (event.target.closest("a")) { 22 closestA = event.target.closest("a"); 23 // There is an A at or above this level in the DOM 24 // ie. they've clicked a link 25 var data = new FormData(); 26 data.append("postID", getPostID()); 27 data.append("location", window.location); 28 data.append("anchor", getAnchor(closestA)); 29 data.append("target", closestA.href); 30 data.append("_user_hash", getCookie("SimpleHistoryLoggingCookie")); 31 var url = ajax_var.url + "ria-track-click/v2/hit/" + window.cachebreak++; 32 navigator.sendBeacon(url, data); 33 } else if (event.target.closest("img")) { 34 closestA = event.target.closest("img"); 35 // There is an A at or above this level in the DOM 36 // ie. they've clicked a link 37 var data = new FormData(); 38 data.append("postID", getPostID()); 39 data.append("location", window.location); 40 data.append("anchor", getAnchor(closestA)); 41 data.append("target", closestA.src); 42 data.append("_user_hash", getCookie("SimpleHistoryLoggingCookie")); 43 var url = ajax_var.url + "ria-track-click/v2/hit/" + window.cachebreak++; 44 navigator.sendBeacon(url, data); 45 } else { 46 clickedItem = event.target; 47 var data = new FormData(); 48 data.append("postID", getPostID()); 49 data.append("location", window.location); 50 data.append("anchor", getAnchor(clickedItem)); 51 data.append("target", jQuery(clickedItem).text()); 52 data.append("_user_hash", getCookie("SimpleHistoryLoggingCookie")); 53 var url = ajax_var.url + "ria-track-click/v2/hit/" + window.cachebreak++; 54 var results = navigator.sendBeacon(url, data); 55 } 56 } 57 58 function getCookie(SimpleHistoryLoggingCookie) { 59 let name = SimpleHistoryLoggingCookie + "="; 60 let decodedCookie = decodeURIComponent(document.cookie); 61 let ca = decodedCookie.split(";"); 62 for (let i = 0; i < ca.length; i++) { 63 let c = ca[i]; 64 while (c.charAt(0) == " ") { 65 c = c.substring(1); 66 } 67 if (c.indexOf(name) == 0) { 68 return c.substring(name.length, c.length); 69 } 70 } 71 return ""; 72 } 73 74 document.addEventListener("click", bubbleBeacon); 75})();
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.