PageSourceSearch

https://viewlofoten.com/language-picker.js?v=dc1ef99e9a2275df

js viewlofoten.com collected 2026-10-10 01:46:46 UTC 1,630 bytes, 26 lines download raw bytes

1document.querySelectorAll('.language-picker').forEach(picker => {
2  const language = value => value.toLowerCase().split('-')[0].replace(/^no$/, 'nb');
3  const sync = () => picker.querySelectorAll('a').forEach(link => {
4    const target = new URL(link.href, location.href);
5    const sameLanguage = language(link.lang) === language(document.documentElement.lang);
6    // Only real equivalent pages retain useful query choices. Fallback links on
7    // untranslated articles always go to the language homepage without filters.
8    if (link.dataset.languageFallback === 'true') {
9      target.search = ''; target.hash = '';
10      link.href = target.pathname;
11      return;
12    }
13    const params = new URLSearchParams(location.search);
14    if (/\/(?:turer|tours|touren|tour|excursions|sok|search|suche|cerca|recherche)\//.test(location.pathname) && !sameLanguage) params.delete('q');
15    target.search = params.toString();
16    target.hash = sameLanguage || picker.dataset.languageFragments === 'preserve' || location.hash === '#innhold' ? location.hash : '';
17    link.href = target.pathname + target.search + target.hash;
18  });
19  picker.addEventListener('toggle', () => { if (picker.open) sync(); });
20  sync();
21  document.addEventListener('click', event => { if (!picker.contains(event.target)) picker.open = false; });
22  picker.addEventListener('keydown', event => {
23    if (event.key === 'Escape' && picker.open) { picker.open = false; picker.querySelector('summary').focus(); event.stopPropagation(); }
24  });
25  picker.addEventListener('focusout', event => { if (!picker.contains(event.relatedTarget)) picker.open = false; });
26});

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.