1(function () { 2 "use strict"; 3 4 var campaignKeys = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"]; 5 var storageKey = "digitrust_campaign"; 6 var maxValueLength = 200; 7 8 function clean(value, maxLength) { 9 if (!value) return ""; 10 return String(value).replace(/[\u0000-\u001f\u007f]/g, "").slice(0, maxLength || maxValueLength); 11 } 12 13 function readStored() { 14 try { 15 return JSON.parse(window.sessionStorage.getItem(storageKey) || "{}"); 16 } catch (error) { 17 return {}; 18 } 19 } 20 21 function writeStored(data) { 22 try { 23 window.sessionStorage.setItem(storageKey, JSON.stringify(data)); 24 } catch (error) { 25 // Attribution is useful but never required for the site to function. 26 } 27 } 28 29 function setupNavigation() { 30 var toggle = document.querySelector("[data-nav-toggle]"); 31 if (!toggle) return; 32 var menuId = toggle.getAttribute("aria-controls"); 33 var menu = menuId ? document.getElementById(menuId) : null; 34 if (!menu) return; 35 36 function setOpen(open) { 37 toggle.setAttribute("aria-expanded", open ? "true" : "false"); 38 toggle.textContent = open ? "Close" : "Menu"; 39 menu.classList.toggle("open", open); 40 } 41 42 toggle.addEventListener("click", function () { 43 setOpen(toggle.getAttribute("aria-expanded") !== "true"); 44 }); 45 46 menu.querySelectorAll("a").forEach(function (link) { 47 link.addEventListener("click", function () { 48 if (window.matchMedia("(max-width: 980px)").matches) setOpen(false); 49 }); 50 }); 51 52 document.addEventListener("keydown", function (event) { 53 if (event.key === "Escape" && toggle.getAttribute("aria-expanded") === "true") { 54 setOpen(false); 55 toggle.focus(); 56 } 57 }); 58 59 window.addEventListener("resize", function () { 60 if (!window.matchMedia("(max-width: 980px)").matches) setOpen(false); 61 }); 62 } 63 64 function setupCampaignAttribution() { 65 var params = new URLSearchParams(window.location.search); 66 var campaign = readStored(); 67 68 campaignKeys.forEach(function (key) { 69 if (params.get(key)) campaign[key] = clean(params.get(key)); 70 }); 71 if (params.get("intent")) campaign.intent = clean(params.get("intent")); 72 writeStored(campaign); 73 74 document.querySelectorAll("[data-campaign-link]").forEach(function (link) { 75 try { 76 var url = new URL(link.getAttribute("href"), window.location.origin); 77 if (url.origin !== window.location.origin) return; 78 campaignKeys.forEach(function (key) { 79 if (campaign[key] && !url.searchParams.get(key)) url.searchParams.set(key, campaign[key]); 80 }); 81 if (campaign.intent && !url.searchParams.get("intent") && url.pathname.indexOf("get-started") !== -1) { 82 url.searchParams.set("intent", campaign.intent); 83 } 84 link.setAttribute("href", url.pathname + url.search + url.hash); 85 } catch (error) { 86 // Leave the original link unchanged when URL parsing fails. 87 } 88 }); 89 90 campaignKeys.concat(["intent"]).forEach(function (key) { 91 var field = document.getElementById(key); 92 if (!field) return; 93 var value = params.get(key) || campaign[key] || ""; 94 field.value = clean(value || field.value); 95 }); 96 97 var referrer = document.getElementById("referrer"); 98 if (referrer) referrer.value = clean(document.referrer || "direct", 500); 99 100 var landingPage = document.getElementById("landing_page"); 101 if (landingPage) landingPage.value = clean(window.location.href, 500); 102 103 var sourcePath = document.getElementById("source_path"); 104 if (sourcePath) sourcePath.value = clean(window.location.pathname, 250); 105 } 106 107 function setupIntakeForm() { 108 var form = document.getElementById("digitrust-intake"); 109 if (!form) return; 110 111 form.addEventListener("submit", function () { 112 var submit = form.querySelector("button[type='submit']"); 113 if (submit) { 114 submit.disabled = true; 115 submit.textContent = "Submitting..."; 116 } 117 }); 118 } 119 120 function setupIntakeStatus() { 121 var status = document.getElementById("intake-status"); 122 if (!status) return; 123 124 var value = new URLSearchParams(window.location.search).get("status"); 125 var messages = { 126 invalid: "Please review the required fields and try again.", 127 "delivery-unavailable": "We could not deliver your request. Please try again or email [email protected].", 128 }; 129 if (!messages[value]) return; 130 131 status.textContent = messages[value]; 132 status.hidden = false;
133 } 134 135 function setCopyrightYear() { 136 document.querySelectorAll("[data-current-year]").forEach(function (node) { 137 node.textContent = String(new Date().getFullYear()); 138 }); 139 } 140 141 setupNavigation(); 142 setupCampaignAttribution(); 143 setupIntakeForm(); 144 setupIntakeStatus(); 145 setCopyrightYear(); 146})();
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.