1// Vanilla JavaScript version - No jQuery dependency 2(function() { 3 'use strict'; 4 5 // Wrap in try-catch to prevent console errors 6 try { 7 // Wait for DOM to be ready 8 if (document.readyState === 'loading') { 9 document.addEventListener('DOMContentLoaded', init); 10 } else { 11 init(); 12 } 13 } catch (err) { 14 // Silent fail - don't log to console in production 15 } 16 17 function init() { 18 try { 19 // Show logic-hide elements 20 document.querySelectorAll('.logic-hide').forEach(function(el) { 21 el.style.display = ''; 22 }); 23 24 var header = document.querySelector('.header'); 25 var scrollTimer; 26 var isScrolled = false; 27 28 function addVisibleClass() { 29 if (!isScrolled && header) { 30 header.classList.add('scrolled'); 31 isScrolled = true; 32 } 33 } 34 35 function removeVisibleClass() { 36 if (isScrolled && header) { 37 header.classList.remove('scrolled'); 38 isScrolled = false; 39 } 40 } 41 42 // Initial state 43 removeVisibleClass(); 44 45 // Optimized scroll handler with debounce 46 window.addEventListener('scroll', function() { 47 var scroll = window.pageYOffset || document.documentElement.scrollTop; 48 49 clearTimeout(scrollTimer); 50 scrollTimer = setTimeout(function() { 51 if (scroll >= 600) { 52 addVisibleClass(); 53 } else { 54 removeVisibleClass(); 55 } 56 }, 100); 57 }, { passive: true }); 58 59 // Cookie functions 60 var getCookie = function(name) { 61 var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); 62 if (match) return match[2]; 63 }; 64 65 var setCookie = function(name, value, days) { 66 var expires = ""; 67 if (days) { 68 var date = new Date(); 69 date.setTime(date.getTime() + (days*24*60*60*1000)); 70 expires = "; expires=" + date.toUTCString(); 71 } 72 document.cookie = name + "=" + (value || "") + expires + "; path=/"; 73 }; 74 75 // Partner key handling 76 var urlParams = new URLSearchParams(window.location.search); 77 var psPartnerKey = urlParams.get("ps_partner_key"); 78 79 if (psPartnerKey) { 80 setCookie("ps_partner_key", window.location.href, 30); 81 } else { 82 psPartnerKey = getCookie("ps_partner_key"); 83 } 84 85 // Close modal handler 86 document.querySelectorAll('.close-modal').forEach(function(el) { 87 el.addEventListener('click', function() { 88 location.reload(); 89 }); 90 }); 91 92 // Form reset function 93 function resetForm() { 94 if (window.location.href.indexOf("create-an-account") === -1) { 95 showElements('#email-form, #email-form form, .create-account-popup .create-form, .step-1'); 96 } else { 97 showElements('#email-form, #email-form form, .create-form, .step-1'); 98 } 99 100 document.querySelectorAll('form').forEach(function(form) { 101 form.reset(); 102 }); 103 104 removeElements('.error-twh'); 105 hideElements('.b2b, .dtc, .step-2'); 106 hideElements('.great-block, .w-form-fail, .w-form-done'); 107 } 108 109 // Utility functions 110 function showElements(selector) { 111 document.querySelectorAll(selector).forEach(function(el) { 112 el.style.display = ''; 113 }); 114 } 115 116 function hideElements(selector) { 117 document.querySelectorAll(selector).forEach(function(el) { 118 el.style.display = 'none'; 119 }); 120 } 121 122 function removeElements(selector) { 123 document.querySelectorAll(selector).forEach(function(el) { 124 el.remove(); 125 }); 126 } 127 128 function isElementVisible(el) { 129 return !!(el && (el.offsetWidth || el.offsetHeight || el.getClientRects().length)); 130 } 131 132 // Great block button handler 133 document.querySelectorAll('.great-block .button-8').forEach(function(el) { 134 el.addEventListener('click', function(event) { 135 resetForm(); 136 }); 137 }); 138 139 140 // Helper function to get field value 141 function getFieldValue(form, selector) { 142 var field = form.querySelector(selector); 143 return field ? field.value : ''; 144 } 145 146 // Modal handlers 147 document.querySelectorAll('.new-footer-btn').forEach(function(el) { 148 el.addEventListener('click', function() { 149 resetForm(); 150 var popup = document.querySelector('.create-account-popup'); 151 if (popup) { 152 popup.style.display = 'block'; 153 setTimeout(function() { popup.style.opacity = '1'; }, 10); 154 } 155 }); 156 }); 157 158 document.querySelectorAll('.account-close-modal').forEach(function(el) { 159 el.addEventListener('click', function() { 160 resetForm(); 161 var popup = document.querySelector('.create-account-popup'); 162 if (popup) { 163 popup.style.opacity = '0'; 164 setTimeout(function() { popup.style.display = 'none'; }, 300); 165 } 166 }); 167 }); 168 169 document.querySelectorAll('.create-account-popup, .popup-start-now').forEach(function(el) { 170 el.addEventListener('click', function(e) { 171 if (e.target === this) { 172 this.style.opacity = '0'; 173 var self = this; 174 setTimeout(function() { self.style.display = 'none'; }, 300); 175 resetForm(); 176 } 177 }); 178 }); 179 180 document.querySelectorAll('.cros-noti').forEach(function(el) { 181 el.addEventListener('click', function() { 182 var noti = document.querySelector('.noti'); 183 if (noti) { 184 noti.style.opacity = '0'; 185 setTimeout(function() { noti.style.display = 'none'; }, 300); 186 } 187 }); 188 }); 189 190 // Section toggle functions 191 function toggleSections(selectedOptionText, dtcSection, b2bSection, agencySection) { 192 if (dtcSection) dtcSection.style.display = selectedOptionText === "DTC" ? '' : 'none'; 193 if (b2bSection) b2bSection.style.display = selectedOptionText === "B2B" ? '' : 'none'; 194 if (agencySection) agencySection.style.display = selectedOptionText === "Agency" ? '' : 'none'; 195 } 196 197 function showWebsiteDetails(websiteDetailsSection) { 198 if (websiteDetailsSection) websiteDetailsSection.style.display = ''; 199 } 200 201 function onBusinessTypeChange(clientTypeField, dtcSection, b2bSection, agencySection, websiteDetailsSection) { 202 var selectedOptionText = clientTypeField.value; 203 toggleSections(selectedOptionText, dtcSection, b2bSection, agencySection); 204 if (selectedOptionText === 'B2B' || selectedOptionText === 'DTC' || selectedOptionText === 'Agency') { 205 showWebsiteDetails(websiteDetailsSection); 206 } 207 } 208 209 // Radio button change handlers 210 document.addEventListener('click', function(e) { 211 var radio = e.target.closest('input[name=radio]'); 212 if (!radio) return; 213 214 var form = radio.closest('form'); 215 if (!form) return; 216 217 var dtcSection = form.querySelector('.dtc'); 218 var b2bSection = form.querySelector('.b2b'); 219 var agencySection = form.querySelector('.agency'); 220 var websiteDetailsSection = form.querySelector('.website-details'); 221 onBusinessTypeChange(radio, dtcSection, b2bSection, agencySection, websiteDetailsSection); 222 223 // Show/hide multi-select based on selection 224 var inputValue = radio.value; 225 var multiSelect = document.querySelector('.multi-select'); 226 if (inputValue === 'DTC') { 227 if (multiSelect) multiSelect.style.display = ''; 228 } else if (inputValue === 'Agency' || inputValue === 'B2B') { 229 if (multiSelect) multiSelect.style.display = 'none'; 230 } 231 232 var column = document.querySelector('.column-3.lp2.etail'); 233 if (column) column.style.marginTop = '0px'; 234 }); 235 236 // Select change handlers 237 document.addEventListener('change', function(e) { 238 if (!e.target.matches('.dtc select, .b2b select, .agency select')) return; 239 240 var form = e.target.closest('form'); 241 if (!form) return; 242 243 var websiteDetailsSection = form.querySelector('.website-details'); 244 if (websiteDetailsSection) websiteDetailsSection.style.display = ''; 245 }); 246 247 // Form submit handler for traffic-based logic 248 document.addEventListener('submit', function(e) { 249 var form = e.target; 250 if (!form.matches('form#email-form, form#email-form-2')) return; 251 252 e.preventDefault(); 253 254 var selectedTraffic = getFieldValue(form, '.dtc select[name="Estimated-Site-Traffic"]'); 255 var selectedTrafficB2b = getFieldValue(form, '.b2b select[name="Estimated-Site-Traffic-B2B"]'); 256 var ecommercePlatform = getFieldValue(document, '.dtc select[name="Ecommerce-Platform"]'); 257 258 var invalidEcommerceValues = ["OTHERS", "UNKNOWN"]; 259 260 if (selectedTraffic === 'Under 10,000') { 261 setDisplay('.step-2 h2.ty, .step-2 .ty-block', 'block'); 262 setDisplay('.step-2 h2.heading-14, .step-2 .w-embed.w-iframe', 'none'); 263 setDisplay('.div-block-11 h1.heading-40, .div-block-11 .text-block-56, .step-1', 'none'); 264 } else if (selectedTrafficB2b === 'Under 5,000') { 265 setDisplay('.step-2 h2.ty, .step-2 .b2b-thankyou', 'block'); 266 setDisplay('.step-2 h2.heading-14, .step-2 .w-embed.w-iframe, .step-2 .ty-block', 'none'); 267 setDisplay('.div-block-11 h1.heading-40, .div-block-11 .text-block-56, .step-1', 'none'); 268 } else if (invalidEcommerceValues.includes(ecommercePlatform) && (selectedTraffic === '10,001 - 20,000')) { 269 setDisplay('.step-2 h2.ty, .step-2 .field-value-block', 'block'); 270 setDisplay('.step-2 .ty-block, .step-2 h2.heading-14, .step-2 .w-embed.w-iframe', 'none'); 271 setDisplay('.div-block-11 h1.heading-40, .div-block-11 .text-block-56, .step-1', 'none'); 272 } else { 273 setDisplay('.step-2 h2.ty, .step-2 .field-value-block, .step-2 .ty-block', 'none'); 274 setDisplay('.step-2 h2.heading-14, .step-2 .w-embed.w-iframe', 'block'); 275 setDisplay('.div-block-11 h1.heading-40, .div-block-11 .text-block-56', 'none'); 276 } 277 }); 278 279 function setDisplay(selector, displayValue) { 280 document.querySelectorAll(selector).forEach(function(el) { 281 el.style.display = displayValue; 282 }); 283 } 284 285 // Check if loaded by iframe 286 if (isLoadedByIframe()) { 287 setDisplay('div.navigation.header', 'none'); 288 setDisplay('div.div-block-18', 'none'); 289 } 290 } catch (err) { 291 // Silent fail - don't log to console in production 292 } 293 } 294 295 function isLoadedByIframe() { 296 var params = new URLSearchParams(window.location.search); 297 return params.has("iframe"); 298 } 299})();
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.