import { buildRedirectionTrigger, loadContextActions } from 'https://static.cloud.coveo.com/atomic/v2/headless/headless.esm.js'; function sleep(ms){ return new Promise( resolver => setTimeout(resolver, ms)); }; function getCookie(cname) { let name = cname + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(let i = 0; i < ca.length; i++) { let c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } }; function isOTEnabled() { const otCookie = getCookie('OptanonConsent'); if( typeof otCookie == 'string'){ return otCookie.includes('C0002:1'); } return true; }; (async () => { await sleep(2000); await customElements.whenDefined('atomic-search-interface'); const productSKU = await document.querySelector('.coveo-product .sku').textContent; const isInternal = typeof getCookie('exclude-from-analytics') != 'undefined'; if(document.querySelector('atomic-search-interface.resource-search')){ const resourceSearchInterface = await document.querySelector('atomic-search-interface.resource-search'); await resourceSearchInterface.initialize({ accessToken: window.DanaherConfig.familyResourceKey, organizationId: window.DanaherConfig.searchOrg, organizationEndpoints: await resourceSearchInterface.getOrganizationEndpoints(window.DanaherConfig.searchOrg) }); const isInternal = typeof getCookie('exclude-from-analytics') != 'undefined'; const resourceSearchEngine = resourceSearchInterface.engine; const resourceSearchAction = loadContextActions(resourceSearchEngine).setContext({ familyid: productSKU, host: window.location.host, internal: isInternal }); resourceSearchEngine.dispatch(resourceSearchAction); if( !isOTEnabled()){ resourceSearchInterface.analytics = false; } resourceSearchInterface.executeFirstSearch(); } if(document.querySelector('atomic-search-interface.product-search')){ const listSearchInterface = await document.querySelector('atomic-search-interface.product-search'); await listSearchInterface.initialize({ accessToken: window.DanaherConfig.familyProductKey, organizationId: window.DanaherConfig.searchOrg, organizationEndpoints: await listSearchInterface.getOrganizationEndpoints(window.DanaherConfig.searchOrg) }); const listSearchEngine = listSearchInterface.engine; const listSearchAction = loadContextActions(listSearchEngine).setContext({ familyid: productSKU, host: window.location.host, internal: isInternal }); listSearchEngine.dispatch(listSearchAction); if( !isOTEnabled()){ listSearchInterface.analytics = false; } listSearchInterface.executeFirstSearch(); } })();