1/** 2 * Accosearch v2 â currency bridge 3 * 4 * The Travelbase accommodation-search widget renders inside a Shadow DOM, 5 * which the global price scanner can't reach. So we hand it the active 6 * currency + EUR-based rate via the `currency` / `currency-rate` attributes 7 * (same contract as accosearch-lapland). The widget currently renders EUR and 8 * ignores these, but keeping the bridge in place means currency support lands 9 * without a travelblox change. 10 * 11 * Loaded only when the block is present (see register-blox.php). 12 */ 13(function () { 14 'use strict'; 15 16 function rateFor(currency) { 17 var rates = (window.tbCurrencyData && window.tbCurrencyData.exchangeRates) || {}; 18 return rates[currency] != null ? rates[currency] : 1; 19 } 20 21 function apply(currency, rate) { 22 document.querySelectorAll('travelbase-accosearch').forEach(function (el) { 23 el.setAttribute('currency', currency); 24 el.setAttribute('currency-rate', String(rate)); 25 }); 26 } 27 28 function syncFromCookie() { 29 var currency = (typeof tb !== 'undefined' && tb.getCookie('tb_user_currency')) || 'EUR'; 30 apply(currency, rateFor(currency)); 31 } 32 33 if (document.readyState === 'loading') { 34 document.addEventListener('DOMContentLoaded', syncFromCookie); 35 } else { 36 syncFromCookie(); 37 } 38 39 window.addEventListener('tb:currency-changed', function (event) { 40 var detail = event.detail || {}; 41 apply(detail.currency || 'EUR', detail.rate != null ? detail.rate : rateFor(detail.currency || 'EUR')); 42 }); 43})();
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.