1jQuery(document).ready(function ($) { 2 const urlParams = new URLSearchParams(window.location.search); 3 var noParams = false; 4 5 //check if params exists 6 if (!urlParams.toString()) { 7 noParams = true; 8 } 9 10 const utmKnock = urlParams.get('utm_knock'); 11 12 $.ajax({ 13 type: 'POST', 14 url: frontend_utmcallajax.ajaxurl, 15 cache: false, 16 data: { 17 action: 'replace_phone_no', 18 utm_knock: utmKnock, 19 noParams: noParams 20 }, 21 success: function (response) { 22 if (response.success) { 23 // Process phone number if available 24 if (response.data.phone_no) { 25 let rawPhone = response.data.phone_no.replace(/[^\d]/g, ''); 26 27 if (rawPhone.length === 10) { 28 const formattedDisplay = `(${rawPhone.slice(0, 3)}) ${rawPhone.slice(3, 6)}-${rawPhone.slice(6)}`; 29 const formattedHref = `tel:${rawPhone.slice(0, 3)}-${rawPhone.slice(3, 6)}-${rawPhone.slice(6)}`; 30 31 $('a[href^="tel:"]').each(function () { 32 if ($(this).parent().hasClass('utm_knock_phone') || $(this).hasClass('utm_knock_phone')) { 33 $(this).attr('href', formattedHref); 34 } else { 35 if ($(this).text().trim() !== '') { 36 $(this).text(formattedDisplay); 37 } 38 $(this).attr('href', formattedHref); 39 } 40 }); 41 } 42 } 43 // Process email if available 44 if (response.data.email) { 45 let formattedEmail = response.data.email; 46 47 $('a[href^="mailto:"]').each(function () { 48 $(this).attr('href', `mailto:${formattedEmail}`); 49 }); 50 } 51 } 52 } 53 }); 54}); 55
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.