1(function () { 2 const STORAGE_KEY = 'segundazoPreferredLanguage'; 3 const SUPPORTED_LOCALES = ['es', 'en', 'pt', 'fr']; 4 5 function localeFromLink(link) { 6 const label = (link.textContent || '').trim().toLowerCase(); 7 if (label.endsWith('en')) return 'en'; 8 if (label.endsWith('pt')) return 'pt'; 9 if (label.endsWith('fr')) return 'fr'; 10 return 'es'; 11 } 12 13 function bindLanguageLinks() { 14 document.querySelectorAll('.language-switcher a[href]').forEach(function (link) { 15 if (link.dataset.languageBound === 'true') return; 16 link.dataset.languageBound = 'true'; 17 link.addEventListener('click', function () { 18 const locale = localeFromLink(link); 19 if (!SUPPORTED_LOCALES.includes(locale)) return; 20 try { 21 window.localStorage.setItem(STORAGE_KEY, locale); 22 } catch (error) { 23 return; 24 } 25 }); 26 }); 27 } 28 29 function bindLanguageDropdown() { 30 document.querySelectorAll('.language-switcher').forEach(function (switcher) { 31 const button = switcher.querySelector('.language-current'); 32 if (!button || button.dataset.headerBound === 'true' || button.dataset.languageToggleBound === 'true') return; 33 34 button.dataset.languageToggleBound = 'true'; 35 button.addEventListener('click', function () { 36 const open = switcher.classList.toggle('is-open'); 37 button.setAttribute('aria-expanded', String(open)); 38 }); 39 }); 40 41 document.addEventListener('click', function (event) { 42 if (event.target.closest('.language-switcher')) return; 43 document.querySelectorAll('.language-switcher.is-open').forEach(function (switcher) { 44 switcher.classList.remove('is-open'); 45 switcher.querySelector('.language-current')?.setAttribute('aria-expanded', 'false'); 46 }); 47 }); 48 } 49 50 bindLanguageDropdown(); 51 bindLanguageLinks(); 52}());
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.