1if (typeof jQuery !== 'undefined') { 2 jQuery(document).ready(function ($) { 3 // console.log("Carregou"); 4 5 6 if (typeof wptools_ajax_object === 'undefined') { 7 // O objeto não foi definido. Retornar impede o erro no navegador. 8 // O console.error opcional ajuda no debug. 9 // console.error('AJAX object (wptools_ajax_object) is not defined. Skipping AJAX call.'); 10 return; 11 } 12 13 14 var loadingTime = performance.now(); 15 // Check if loadingTime is a valid number 16 if (!isNaN(loadingTime) && loadingTime > 0) { 17 // Convert to seconds 18 var loadingTimeInSeconds = loadingTime / 1000; 19 } else { 20 console.error('Invalid loading time value.'); 21 return; 22 } 23 var urlWithDomain = window.location.href; 24 // Check if the variable is defined and not null, empty, or consists only of whitespace 25 if (urlWithDomain && urlWithDomain.trim() !== "") { 26 // The variable is defined and not null, empty, or consists only of whitespace 27 // Proceed with the code here 28 //console.log("The urlWithDomain variable is correct:", urlWithDomain); 29 } else { 30 console.log("The urlWithDomain variable is not correct."); 31 return; 32 } 33 34 function extractBaseURL(urlWithDomain) { 35 var urlWithoutDomain = urlWithDomain.replace(/^(https?:\/\/)?(www\.)?[^\/]+\/?(.*)$/, "$3"); 36 if (urlWithoutDomain === "") { 37 return "/"; 38 } 39 if (urlWithoutDomain.endsWith("/")) { 40 urlWithoutDomain = urlWithoutDomain.slice(0, -1); 41 } 42 return urlWithoutDomain; 43 } 44 var url = extractBaseURL(urlWithDomain); 45 // Check if the URL is valid before logging 46 if (typeof url === 'string' && url.length > 0) { 47 //console.log("ajax: " + loadingTimeInSeconds); 48 49 50 //console.log('Nonce:', wptools_ajax_object.ajax_nonce); 51 //console.log('url:', url); 52 53 var data = { 54 action: 'wptools_register_loading_time3', 55 page_url: url, 56 loading_time: loadingTimeInSeconds, 57 nonce: wptools_ajax_object.ajax_nonce 58 }; 59 jQuery.ajax({ 60 url: wptools_ajax_object.ajax_url, 61 type: 'POST', 62 data: data, 63 success: function (data) { 64 // This outputs the result of the ajax request 65 // console.log(data); 66 }, 67 error: function (jqXHR, textStatus, errorThrown) { 68 console.group("AJAX Error"); 69 console.error("Status textual:", textStatus); 70 console.error("Código HTTP:", jqXHR.status); 71 console.error("Erro lançado:", errorThrown); 72 console.error("Resposta do servidor:", jqXHR.responseText); 73 console.groupEnd(); 74 } 75 }); 76 } else { 77 console.error('Invalid URL! ' + url); 78 } 79 }); 80}
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.