1function setCookie(name, value, days) { 2 console.log("set cookie - " + name + ": " + value); 3 let expires = ""; 4 if (days) { 5 let date = new Date(); 6 date.setTime(date.getTime() + 5 * 60 * 1000); 7 expires = "; expires=" + date.toUTCString(); 8 } 9 document.cookie = name + "=" + (value || "") + expires + "; path=/"; 10} 11 12function getCookie(name) { 13 const nameEQ = name + "="; 14 const ca = document.cookie.split(";"); 15 for (let i = 0; i < ca.length; i++) { 16 let c = ca[i]; 17 while (c.charAt(0) == " ") c = c.substring(1, c.length); 18 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 19 } 20 return null; 21} 22 23// Saves UTM parameters to submit with contact form 24document.addEventListener("DOMContentLoaded", function () { 25 var sPageURL = decodeURIComponent(window.location.search.substring(1)), 26 sURLVariables = sPageURL.split("&"), 27 sParameterName, 28 i, 29 x; 30 var urlParams = [ 31 "utm_ad_group", 32 "utm_source", 33 "utm_campaign", 34 "utm_medium", 35 "utm_content", 36 "utm_term", 37 "gclid", 38 "GCLID", 39 ]; 40 var paramValues = []; 41 for (i = 0; i < sURLVariables.length; i++) { 42 sParameterName = sURLVariables[i].split("="); 43 if (urlParams.includes(sParameterName[0])) { 44 setCookie(sParameterName[0], sParameterName[1], 0); 45 paramValues.push(sParameterName[0]); 46 } 47 } 48 49 for (x = 0; x < urlParams.length; x++) { 50 if (getCookie(urlParams[x])) { 51 if (document.querySelector('input[name="' + urlParams[x] + '"]')) { 52 document.querySelector( 53 'input[name="' + urlParams[x] + '"]' 54 ).value = getCookie(urlParams[x]); 55 } 56 57 var lowerParam = urlParams[x]; 58 var lowerCaseParam = lowerParam.toLowerCase(); 59 if (document.querySelector('input[name="' + lowerCaseParam + '"]')) { 60 document.querySelector( 61 'input[name="' + lowerCaseParam + '"]' 62 ).value = getCookie(urlParams[x]); 63 } 64 } 65 } 66});
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.