PageSourceSearch

https://dombud.eu/wp-content/themes/avanam-toolpart/assets/js/currency-switcher.js?ver=1790259697

js dombud.eu collected 2026-10-07 14:19:09 UTC 4,305 bytes, 34 lines download raw bytes

1(()=>{'use strict';const root=document.getElementById('dombud-currency-switcher');if(!root)return;const available=root.dataset.eurAvailable==='1';const media=matchMedia('(max-width: 767px)');const valid=value=>value==='EUR'&&available?'EUR':'PLN';let selected=valid(sessionStorage.getItem('dombud_currency')||((document.cookie.match(/(?:^|; )dombud_currency=([^;]+)/)||[])[1]||'PLN').toUpperCase());const move=()=>{const language=document.getElementById('dombud-language-switcher');if(language?.isConnected){language.after(root);return;}const target=media.matches?document.querySelector('#mobile-drawer .drawer-content'):document.querySelector('.site-header .header-account-wrap');if(target)media.matches?target.prepend(root):target.before(root);};const placeNotice=()=>{const note=document.getElementById('dombud-currency-note');if(!note)return;if(document.body.classList.contains('single-product')){const anchor=document.querySelector('.summary .dombud-currency-price');if(anchor)anchor.after(note);}else{const grid=document.querySelector('.products');if(grid)grid.before(note);}};const checkoutNotice=()=>{const note=document.getElementById('dombud-checkout-currency-note');if(!note)return;const form=document.querySelector('form.checkout');if(form&&!form.contains(note))form.prepend(note);note.hidden=selected!=='EUR';};const apply=()=>{document.documentElement.dataset.dombudCurrency=selected;root.querySelectorAll('[data-dombud-currency]').forEach(button=>button.setAttribute('aria-pressed',String(button.dataset.dombudCurrency===selected)));document.querySelectorAll('[data-dombud-price-currency]').forEach(price=>{price.hidden=price.dataset.dombudPriceCurrency!==selected;});const note=document.getElementById('dombud-currency-note');if(note)note.hidden=selected!=='EUR';document.querySelectorAll('input[name="dombud_product_enquiry_currency"]').forEach(input=>{input.value=selected;});checkoutNotice();};const save=(value,manual=false)=>{selected=valid(value);sessionStorage.setItem('dombud_currency',selected);if(manual)sessionStorage.setItem('dombud_currency_manual','1');document.cookie=`dombud_currency=${selected}; path=/; SameSite=Lax`;apply();};root.addEventListener('click',event=>{const button=event.target.closest('[data-dombud-currency]');if(button&&!button.disabled)save(button.dataset.dombudCurrency,true);});move();placeNotice();apply();media.addEventListener?.('change',()=>{move();placeNotice();});if(window.jQuery)window.jQuery(document.body).on('found_variation woosq_loaded updated_wc_div updated_checkout wc_fragments_refreshed',()=>setTimeout(()=>{apply();placeNotice();},0));new MutationObserver(mutations=>{if(mutations.some(m=>[...m.addedNodes].some(n=>n.nodeType===1&&(n.matches?.('[data-dombud-currency-price],form.checkout')||n.querySelector?.('[data-dombud-currency-price],form.checkout')))))apply();}).observe(document.body,{childList:true,subtree:true});window.dombudCurrency={current:()=>selected,set:save};})();
2
3/* QA6 multitab currency sync */
4(()=>{try{
5  const CH='dombud_prefs_sync_v1';
6  const bc=('BroadcastChannel' in window)?new BroadcastChannel(CH):null;
7  const applyFromPeer=(cur)=>{
8    if(!cur||(cur!=='PLN'&&cur!=='EUR'))return;
9    if((sessionStorage.getItem('dombud_currency')||'PLN')===cur)return;
10    sessionStorage.setItem('dombud_currency',cur);
11    sessionStorage.setItem('dombud_currency_manual','1');
12    const k='dombud_cur_reload_at';
13    const now=Date.now();
14    const last=Number(sessionStorage.getItem(k)||0);
15    if(now-last<1500)return;
16    sessionStorage.setItem(k,String(now));
17    location.reload();
18  };
19  window.addEventListener('storage',(e)=>{
20    if(e.key==='dombud_currency'&&e.newValue)applyFromPeer(e.newValue);
21  });
22  bc&&bc.addEventListener('message',(ev)=>{
23    if(ev?.data?.type==='currency'&&ev.data.value)applyFromPeer(ev.data.value);
24  });
25  const root=document.getElementById('dombud-currency-switcher');
26  root?.addEventListener('click',()=>{
27    setTimeout(()=>{
28      const cur=sessionStorage.getItem('dombud_currency')||'PLN';
29      try{localStorage.setItem('dombud_currency',cur);}catch(e){}
30      try{bc&&bc.postMessage({type:'currency',value:cur});}catch(e){}
31    },0);
32  },true);
33  try{localStorage.setItem('dombud_currency',sessionStorage.getItem('dombud_currency')||'PLN');}catch(e){}
34}catch(e){}})();

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.