1(function () { 2 const COOKIE_NAME = 'hp_demo_1'; 3 const COOKIE_DAYS = 90; 4 5 const forceControl = window.hpDemoAB && window.hpDemoAB.forceControl === '1'; 6 7 function getCookie(name) { 8 const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)')); 9 return match ? decodeURIComponent(match[1]) : null; 10 } 11 12 function setCookie(name, value, days) { 13 const expires = new Date(Date.now() + days * 864e5).toUTCString(); 14 document.cookie = name + '=' + encodeURIComponent(value) + 15 '; expires=' + expires + '; path=/' + 16 (location.protocol === 'https:' ? '; Secure' : '') + 17 '; SameSite=Lax'; 18 } 19 20 function applyVariant(variant) { 21 const wrapButton = document.querySelector('.wrap_button'); 22 const demoBoxWrapper = document.querySelector('.demo_box-wrapper'); 23 const interactiveDemo = document.querySelector('.interactive-demo-box'); 24 25 if (variant === 'test') { 26 if (demoBoxWrapper) demoBoxWrapper.style.display = 'flex'; 27 if (interactiveDemo) interactiveDemo.style.display = ''; 28 document.body.classList.add('hp-demo-test'); 29 } else { 30 if (wrapButton) wrapButton.style.display = ''; 31 document.body.classList.remove('hp-demo-test'); 32 } 33 } 34 35 function init() { 36 if (forceControl) { 37 applyVariant('control'); 38 return; 39 } 40 41 const cookieVal = getCookie(COOKIE_NAME); 42 if (cookieVal === 'control' || cookieVal === 'test') { 43 applyVariant(cookieVal); 44 return; 45 } 46 47 if (window.posthog && typeof posthog.onFeatureFlags === 'function') { 48 posthog.onFeatureFlags(function () { 49 const flag = posthog.getFeatureFlag(COOKIE_NAME); 50 const variant = (flag === 'test') ? 'test' : 'control'; 51 setCookie(COOKIE_NAME, variant, COOKIE_DAYS); 52 applyVariant(variant); 53 }); 54 } else { 55 applyVariant('control'); 56 } 57 } 58 59 if (document.readyState === 'loading') { 60 document.addEventListener('DOMContentLoaded', init); 61 } else { 62 init(); 63 } 64})();
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.