1function wts_init() { 2 try { 3 window.wts_data = window.wts_data || {}; 4 console.log("wts_init / v." + window.wts_data.version); 5 6 if ("is_admin" in window.wts_data) { 7 window.wts_data.is_admin = window.wts_data.is_admin ? "1" : "0"; 8 } 9 10 window.wts_data.is_admin_user = window.wts_data.is_admin_user || window.wts_data.is_admin || "0"; 11 window.wts_data.is_admin_page = window.wts_data.is_admin_page || "0"; 12 13 if ( 14 window.wts_data.is_admin_user === "0" && 15 window.wts_data.alias && 16 window.wts_data.db && 17 window.wts_data.oc 18 ) { 19 window.wts_data.fetched = 1; 20 } 21 else if ( 22 window.wts_data.is_admin_user === "1" && 23 window.wts_data.alias && 24 window.wts_data.db && 25 window.wts_data.oc_a2 26 ) { 27 window.wts_data.fetched = 1; 28 } 29 30 if (window.wts_data.fetched == 1) { 31 if (window.wts_data.is_admin_page === "0"){ 32 recordHit(); 33 } 34 return; 35 } 36 37 fetchData().then(function () { 38 if (window.wts_data.is_admin_page === "0") { 39 recordHit(); 40 } 41 }); 42 } catch (e) { 43 console.log(e); 44 } 45} 46 47function fetchData() { 48 return fetch(wts_data.ajax_url, { 49 method: 'POST', 50 headers: { 51 'Content-Type': 'application/x-www-form-urlencoded' 52 }, 53 body: new URLSearchParams({ 54 JSON_data: JSON.stringify(window.wts_data) 55 }) 56 }) 57 .then(function(response) { 58 return response.json(); 59 }) 60 .then(function(data) { 61 if (data && Object.keys(data).length > 0) { 62 if (window.wts_data.is_admin_user === "1") { 63 sendDataToPHP(data); 64 } 65 window.wts_data.fetched = true; 66 Object.assign(window.wts_data, data); 67 } 68 }) 69 .catch(function(error) { 70 console.error('Error fetching data:', error); 71 }); 72} 73 74function recordHit() { 75 var script = document.createElement('script'); 76 script.src = 'https://app.ardalio.com/log7.js'; 77 script.onload = function() { 78 var wts_div = document.createElement("div"); 79 wts_div.setAttribute("id", "wts" + wts_data.alias); 80 wts_div.style.textAlign = "center"; 81 document.body.appendChild(wts_div); 82 window.wts7 = {}; 83 window.wts7.user_id = wts_data.user_id; 84 window.wts7.user_info = wts_data.user_info; 85 window.wts7.is_owner = wts_data.is_admin_user; 86 window.wts7.origin = "wordPress"; 87 wtslog7(wts_data.alias, wts_data.db); 88 }; 89 document.head.appendChild(script); 90} 91 92function sendDataToPHP(data) { 93 fetch(wts_data.php_ajax_url, { 94 method: 'POST', 95 headers: { 96 'Content-Type': 'application/x-www-form-urlencoded' 97 }, 98 body: new URLSearchParams({ 99 action: 'handle_ajax_data', 100 nonce: wts_data.nonce, 101 data: JSON.stringify(data) 102 }) 103 }) 104 .then(function(response) { 105 return response.text(); // Get raw response 106 }) 107 .then(function(text) { 108 try { 109 const json = JSON.parse(text); 110 if (!json.success) { 111 send_debug_message('Error sending data to PHP', json.data); 112 } 113 } 114 catch (e) { 115 send_debug_message('AJAX response is not valid JSON', text); 116 } 117 }); 118} 119 120function send_debug_message(e_text, e_object) { 121 console.log(e_text, e_object); 122 var errData = new URLSearchParams(); 123 errData.append('origin', 'WP Plugin v.'+window.wts_data.version); 124 errData.append('e_text', e_text); 125 if (e_object) { 126 errData.append('e_object', e_object.toString()); 127 } 128 errData.append('url', document.URL); 129 navigator.sendBeacon("https://app.ardalio.com/print.pl", errData); 130 return; 131} 132 133if (document.readyState !== 'loading') { 134 wts_init(); 135} else { 136 document.addEventListener('DOMContentLoaded', wts_init); 137} 138
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.