1// Function to get URL parameter by name 2function getUrlParameter(name) { 3 const urlParams = new URLSearchParams(window.location.search); 4 return urlParams.get(name); 5} 6 7// Function to set a cookie 8function setCookie(name, value, days) { 9 const date = new Date(); 10 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 11 document.cookie = `${name}=${value}; expires=${date.toUTCString()}; path=/`; 12} 13 14// Function to get a cookie by name 15function getCookie(name) { 16 const cookies = document.cookie.split('; '); 17 for (const cookie of cookies) { 18 const [key, value] = cookie.split('='); 19 if (key === name) return value; 20 } 21 return null; 22} 23 24// Main function to handle cmpn parameter 25(function handleCmpnParameter() { 26 const cmpnParam = getUrlParameter('cmpn'); // Get 'cmpn' from URL 27 28 if (cmpnParam) { 29 // Store in sessionStorage and cookie 30 sessionStorage.setItem('cmpn', cmpnParam); 31 setCookie('cmpn', cmpnParam, 7); // Set cookie for 7 days 32 } 33 34 // Retrieve from sessionStorage or cookie 35 const storedCmpn = sessionStorage.getItem('cmpn') || getCookie('cmpn'); 36 37 // Dynamically find input fields with `name` containing 'cmpn' 38 if (storedCmpn) { 39 const cmpnInputFields = document.querySelectorAll('input[name*="cmpn"]'); 40 cmpnInputFields.forEach((field) => { 41 field.value = storedCmpn; // Populate each matching input field with the stored value 42 //console.log(`Populating field: ${field.name} with value: ${storedCmpn}`); 43 }); 44 } 45})();
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.