PageSourceSearch

https://global.sennheiser-hearing.com/cdn/shop/t/37/assets/new-cou…?v=43498170658308787951788346259

js sennheiser-hearing.com collected 2026-09-24 08:45:29 UTC 13,601 bytes, 97 lines download raw bytes

1let countryData;function loadCountrySwitcher(){fetch(window.CountrySwitcherConfig.jsonUrl).then(res=>res.json()).then(data=>{countryData=data;const currentStore=getCurrentStore(countryData.regions);updateCurrentStoreHeader(currentStore),createTabs(countryData.regions,currentStore),createCountries(countryData.regions,currentStore);const $toggle2=$("header #locationDropdownToggle"),$panel2=$("header #locationSlidePanel"),$closeBtn2=$("header #locationPanelClose"),$dropdown2=$("header .location-dropdown");countrySwitcher()}),document.querySelector(".location-search-input").addEventListener("input",function(){const keyword=this.value.trim().toLowerCase(),tabs=document.querySelector(".location-regions-tabs"),content=document.querySelector(".location-regions-content"),resultWrapper=document.querySelector(".location-search-results");if(resultWrapper.setAttribute("data-wg-notranslate",""),!keyword){tabs.style.display="",content.style.display="",resultWrapper.style.display="none",resultWrapper.innerHTML="";return}tabs.style.display="none",content.style.display="none",resultWrapper.style.display="block",resultWrapper.innerHTML="",countryData.regions.forEach(region=>{let matchedCountries="";region.countries.forEach(country=>{if(country.name.toLowerCase().includes(keyword)){const currentStore=getCurrentStore(countryData.regions);matchedCountries+=createCountryCard(country,currentStore)}}),matchedCountries&&(resultWrapper.innerHTML+=`
2                    <div class="search-region">
3                        <h3 class="region-title">${region.name}</h3>
4
5                        <div class="countries-grid">
6                            ${matchedCountries}
7                        </div>
8                    </div>
9                `)})})}function openPanel($panel2,$dropdown2){$panel2.is(":visible")||($("body").hasClass("open-nav-menu")&&$(".header .mobile-hamburger-wrapper").trigger("click"),$panel2.stop(!0,!0).slideDown(),$dropdown2.addClass("active"),$("body").addClass("store-locator-opened").css("overflow","hidden"))}function closePanel($panel2,$dropdown2){$panel2.is(":visible")&&($panel2.stop(!0,!0).slideUp(),$dropdown2.removeClass("active"),$("body").removeClass("store-locator-opened").css("overflow",""))}function getCurrentStore(regions){const currentUrl=window.location.href.toLowerCase();let matchedStore=null,longestMatch=-1;return regions.forEach(region=>{region.countries.forEach(country=>
9{country.languages.forEach(language=>{const languageUrl=new URL(language.url.toLowerCase()),compareUrl=languageUrl.origin+languageUrl.pathname.replace(/\/$/,"");(window.location.origin.toLowerCase()+window.location.pathname.toLowerCase()).startsWith(compareUrl)&&compareUrl.length>longestMatch&&(longestMatch=compareUrl.length,matchedStore={region,country,language})})})}),matchedStore}function createTabs(regions,currentStore){const container=document.querySelector(".location-regions-tabs");container.innerHTML="";const hasActiveMatch=!!currentStore&&regions.some(region=>region.name===currentStore.region.name);regions.forEach((region,index)=>{const target=`region-${region.name.toLowerCase().replace(/\s+/g,"-")}`,isActive=hasActiveMatch?currentStore.region.name===region.name:index===0;container.innerHTML+=`
10            <button class="region-tab ${isActive?"active":""}"
11                data-target="${target}">
12                ${region.name}
13            </button>
14        `})}function isMobileViewport(){return window.innerWidth<=767}function createCountries(regions,currentStore){const wrapper=document.querySelector(".location-regions-content");wrapper.setAttribute("data-wg-notranslate",""),wrapper.innerHTML="";const onMobile=isMobileViewport(),hasActiveMatch=!!currentStore&&regions.some(region=>region.name===currentStore.region.name);regions.forEach((region,index)=>{const dest=`region-${region.name.toLowerCase().replace(/\s+/g,"-")}`;let html=`
15
16        <div class="region-content-group ${(hasActiveMatch?currentStore.region.name===region.name:index===0)?"active":""}"
17        id="${dest}">
18
19        <h3 class="region-title">${region.name}</h3>
20
21        <div class="countries-grid">
22
23        `,countriesToRender=region.countries;if(onMobile&&currentStore&&currentStore.region.name===region.name){const activeCode=currentStore.country.country_code,active=region.countries.filter(c=>c.country_code===activeCode),rest=region.countries.filter(c=>c.country_code!==activeCode);countriesToRender=[...active,...rest]}countriesToRender.forEach(country=>{html+=createCountryCard(country,currentStore)}),html+=`
24
25        </div>
26
27        </div>
28
29        `,wrapper.innerHTML+=html})}function bindLanguageSwitcher(){document.addEventListener("click",async function(e){const link=e.target.closest(".country-languages a");if(!link)return;e.preventDefault();const targetUrl=link.href,currentStore=getCurrentStore(countryData.regions);
29let selectedCountry=null,selectedLanguage=null;outer:for(const region of countryData.regions)for(const country of region.countries)for(const language of country.languages){const target=new URL(targetUrl),lang=new URL(language.url);if(target.origin===lang.origin&&target.pathname.replace(/\/$/,"")===lang.pathname.replace(/\/$/,"")){selectedCountry=country,selectedLanguage=language;break outer}}if(!selectedCountry||!selectedLanguage){window.location.href=targetUrl;return}if(!currentStore?.country||selectedCountry.country_code!==currentStore.country.country_code){window.location.href=targetUrl;return}let pagePath=window.location.pathname;const stripTrailingSlash=p=>p.replace(/\/$/,""),currentLocale=stripTrailingSlash(new URL(currentStore.language.url).pathname);currentLocale!==""&&(stripTrailingSlash(pagePath)===currentLocale?pagePath="/":pagePath.startsWith(currentLocale+"/")&&(pagePath=pagePath.substring(currentLocale.length))),pagePath.startsWith("/")||(pagePath="/"+pagePath);const finalUrl=new URL(selectedLanguage.url).origin+stripTrailingSlash(new URL(selectedLanguage.url).pathname)+(pagePath==="/"?"":pagePath);try{const response=await fetch(finalUrl,{method:"HEAD",redirect:"follow"});window.location.href=(response.ok,finalUrl)}catch{window.location.href=finalUrl}})}function createCountryCard(country,currentStore){const isActiveCountry=currentStore&&currentStore.country.country_code===country.country_code;let languages="";const cartIcon=country.is_cart?`
30    <div class="icon-wrap mobile">
31        <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
32            <path d="M7.5 14.9999C8.1903 14.9999 8.74991 15.5596 8.75 16.2499C8.75 16.9402 8.19036 17.4999 7.5 17.4999C6.8097 17.4998 6.25 16.9402 6.25 16.2499C6.25009 15.5596 6.80975 14.9999 7.5 14.9999ZM13.75 14.9999C14.4403 14.9999 14.9999 15.5596 15 16.2499C15 16.9402 14.4404 17.4999 13.75 17.4999C13.0597 17.4998 12.5 16.9402 12.5 16.2499C12.5001 15.5596 13.0598 14.9999 13.75 14.9999ZM5.3877 4.99988H16.875V5.80652L16.7812 5.96277L13.4756 11.2499H7.75684L6.9502 12.038C6.85703 12.1227 6.79175 12.2338 6.7627 12.3563C6.73374 12.4788 6.74193 12.607 6.78711 12.7245C6.83232 12.8419 6.91205 12.9431 7.01562 13.0145C7.11942 13.086 7.24313 13.1245 7.36914 13.1249H15V14.3749H7.36914C6.99257 14.3725 6.62532 14.2568 6.31543 14.0428C6.00549 13.8288 5.76644 13.5261 5.63086 13.1747C5.49546 12.8235 5.46899 12.4396 5.55469 12.0731C5.64052 11.7065 5.83496 11.3737 6.1123 11.119L6.7373 10.494L3.9873 4.99988H2.5V3.74988H4.7627L5.3877 4.99988ZM7.8877 9.99988H12.7812L15.125 6.24988H6.0127L7.8877 9.99988Z" fill="white"/>
33        </svg>
34    </div>
35    `:"";
35return country.languages.forEach(language=>{const isActive=currentStore&&currentStore.language.url.toLowerCase()===language.url.toLowerCase();languages+=`
36            <li>
37                <a
38                    href="${language.url}"
39                    data-language="${language.code}"
40                    data-country="${country.country_code}"
41                    class="${isActive?"active":""}">
42                    <span>${language.code}</span>
43                    <div class="tooltip-block">
44                        ${language.name}
45                    </div>
46                </a>
47            </li>`}),`
48
49    <div class="country-card ${isActiveCountry?"active":""}">
50         <div class="country-flag">
51        ${country.flag?.trim()?`
52           <img src="${country.flag}" alt="${country.name} flag">
53           
54        `:""}
55         </div>
56
57        <div class="country-details">
58            <div class="left-wrap">
59                <div class="country-name">
60                    <span>
61                        ${country.name}
62                    </span>
63                    ${cartIcon}
64                </div>
65
66                <ul class="country-languages">
67                    ${languages}
68                </ul>
69            </div>
70
71            ${country.is_cart?`
72                <div class="icon-wrap desktop">
73                    <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
74                        <path d="M7.5 14.9999C8.1903 14.9999 8.74991 15.5596 8.75 16.2499C8.75 16.9402 8.19036 17.4999 7.5 17.4999C6.8097 17.4998 6.25 16.9402 6.25 16.2499C6.25009 15.5596 6.80975 14.9999 7.5 14.9999ZM13.75 14.9999C14.4403 14.9999 14.9999 15.5596 15 16.2499C15 16.9402 14.4404 17.4999 13.75 17.4999C13.0597 17.4998 12.5 16.9402 12.5 16.2499C12.5001 15.5596 13.0598 14.9999 13.75 14.9999ZM5.3877 4.99988H16.875V5.80652L16.7812 5.96277L13.4756 11.2499H7.75684L6.9502 12.038C6.85703 12.1227 6.79175 12.2338 6.7627 12.3563C6.73374 12.4788 6.74193 12.607 6.78711 12.7245C6.83232 12.8419 6.91205 12.9431 7.01562 13.0145C7.11942 13.086 7.24313 13.1245 7.36914 13.1249H15V14.3749H7.36914C6.99257 14.3725 6.62532 14.2568 6.31543 14.0428C6.00549 13.8288 5.76644 13.5261 5.63086 13.1747C5.49546 12.8235 5.46899 12.4396 5.55469 12.0731C5.64052 11.7065 5.83496 11.3737 6.1123 11.119L6.7373 10.494L3.9873 4.99988H2.5V3.74988H4.7627L5.3877 4.99988ZM7.8877 9.99988H12.7812L15.125 6.24988H6.0127L7.8877 9.99988Z" fill="white"/>
75                    </svg>
76                </div>
77            `:""}
78        </div>
79
80    </div>`}function updateCurrentStoreHeader(currentStore){if(!currentStore)return;const flagImg=document.querySelector(".location-selector .flag-icon img"),countryName=document.querySelector(".location-selector .country-name");if(flagImg&&(flagImg.src=currentStore.country.flag,flagImg.alt=currentStore.country.name),flagImg){const flag=currentStore.country.flag;flag?.trim()?(flagImg.src=flag,flagImg.alt=currentStore.country.name):(flagImg.parentElement.style.display="none",$("#locationDropdownToggle").addClass("no-flag"))}countryName&&(countryName.textContent=currentStore.country.country_code);const selectedFlag=document.getElementById("selectedCountryFlag"),selectedCountryName=document.getElementById("selectedCountryName"),selectedLanguage=document.getElementById("selectedCountryLanguage");if(selectedFlag){const flag=currentStore.country.flag;flag?.trim()?(selectedFlag.src=flag,selectedFlag.alt=currentStore.country.name):selectedFlag.style.display="none"}if(selectedCountryName&&(selectedCountryName.textContent=currentStore.country.name),selectedLanguage){let languagesHtml="";
80currentStore.country.languages.forEach(language=>{const isActive=currentStore.language.url.toLowerCase()===language.url.toLowerCase();languagesHtml+=`
81                <li>
82                    <a
83                        href="${language.url}"
84                        data-language="${language.code}"
85                        data-country="${currentStore.country.country_code}"
86                        class="${isActive?"active":""}">
87                        <span>${language.code.toUpperCase()}</span>
88                        <div class="tooltip-block">
89                            ${language.name}
90                        </div>
91                    </a>
92                </li>`}),selectedLanguage.innerHTML=`
93            <ul class="country-languages selected-country-languages">
94                ${languagesHtml}
95            </ul>
96        `}const regionId=`region-${currentStore.region.name.toLowerCase().replace(/\s+/g,"-")}`;document.querySelectorAll(".region-tab").forEach(tab=>{tab.classList.toggle("active",tab.dataset.target===regionId)}),document.querySelectorAll(".region-content-group").forEach(group=>{group.classList.toggle("active",group.id===regionId)}),document.querySelectorAll(".country-languages a").forEach(link=>{link.classList.remove("active"),link.dataset.country===currentStore.country.country_code&&link.dataset.language.toLowerCase()===currentStore.language.code.toLowerCase()&&link.classList.add("active")})}loadCountrySwitcher(),bindLanguageSwitcher();const $toggle=$("header #locationDropdownToggle"),$panel=$("header #locationSlidePanel"),$closeBtn=$("header #locationPanelClose"),$dropdown=$("header .location-dropdown");$toggle.on("click",function(e){e.stopPropagation(),$panel.is(":visible")?closePanel($panel,$dropdown):openPanel($panel,$dropdown)}),$closeBtn.on("click",function(){closePanel($panel,$dropdown)}),$(document).on("click",function(e){$panel.is(":visible")&&!$panel.is(e.target)&&$panel.has(e.target).length===0&&!$toggle.is(e.target)&&$toggle.has(e.target).length===0&&closePanel($panel,$dropdown)}),$(".location-slide-panel").on("click",".region-tab",function(){const target=$(this).data("target");$(".location-slide-panel .region-tab").removeClass("active"),$(".location-slide-panel .region-content-group").removeClass("active"),$(this).addClass("active"),$("#"+target).addClass("active")});
97//# sourceMappingURL=/cdn/shop/t/37/assets/new-country-switcher.js.map?v=43498170658308787951788346259

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.