/* NO-FLICKER FIX: Hide prices until sync occurs */ .srt-price-display { transition: opacity 0.2s ease-in; opacity: 1; } .srt-loading .srt-price-display, .srt-loading .srt-currency-btn { opacity: 0; pointer-events: none; } /* Highlight for active currency */ .currency-btn.active { background-color: white !important; color: #2563eb !important; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important; } .currency-btn:not(.active) { color: #9ca3af !important; background-color: transparent !important; } activities – srinternationals
/** * GLOBAL PRICE & WHATSAPP SYNC */ function syncDisplayPrices() { const pref = localStorage.getItem('srt_pref_currency'); const currency = pref || 'USD'; // Auto-detect ONLY if no preference exists in this browser if (!pref) { detectUserLocation(); // We don't return here, we sync with USD initially so the page is readable } // 1. Update Visual Prices const priceElements = document.querySelectorAll('.srt-price-display'); priceElements.forEach(el => { const val = el.getAttribute('data-' + currency.toLowerCase()); if (val) el.innerText = val; }); // 2. Update WhatsApp Booking Data document.querySelectorAll('[data-wa-num]').forEach(el => { const num = el.getAttribute('data-wa-num'); const title = el.getAttribute('data-wa-title'); const duration = el.getAttribute('data-wa-duration') || ''; const price = el.getAttribute('data-wa-price-' + currency.toLowerCase()); const msg = `Hi, I'm interested in booking:\n*${title}*\nPrice: ${price}\nDuration: ${duration}`; const encodedMsg = encodeURIComponent(msg); if (el.tagName === 'A') { el.setAttribute('href', `https://wa.me/${num}?text=${encodedMsg}`); } else { el.onclick = (e) => { e.preventDefault(); window.open(`https://wa.me/${num}?text=${encodedMsg}`, '_blank'); }; } }); // 3. Update Visual Switcher Buttons ['btn-', 'm-btn-'].forEach(prefix => { const inrBtn = document.getElementById(prefix + 'inr'); const usdBtn = document.getElementById(prefix + 'usd'); if (inrBtn && usdBtn) { if (currency === 'INR') { inrBtn.classList.add('active'); usdBtn.classList.remove('active'); } else { usdBtn.classList.add('active'); inrBtn.classList.remove('active'); } } }); // 4. Update the Root HTML class and reveal content const root = document.documentElement; root.classList.remove('srt-currency-inr', 'srt-currency-usd', 'srt-loading'); root.classList.add('srt-currency-' + currency.toLowerCase()); // Dispatch a custom event in case carousels or archives need to react window.dispatchEvent(new CustomEvent('srtCurrencyChanged', { detail: { currency } })); } function detectUserLocation() { if (sessionStorage.getItem('srt_detection_tried')) return; sessionStorage.setItem('srt_detection_tried', 'true'); fetch('https://ip-api.com/json/?fields=countryCode') .then(res => res.json()) .then(data => { const detected = data.countryCode === 'IN' ? 'INR' : 'USD'; localStorage.setItem('srt_pref_currency', detected); document.cookie = "srt_currency=" + detected + ";max-age=2592000;path=/"; // Critical: Sync UI with the newly detected currency with a small safety delay setTimeout(syncDisplayPrices, 50); }) .catch(() => { localStorage.setItem('srt_pref_currency', 'USD'); syncDisplayPrices(); }); } function changeCurrency(currency) { document.documentElement.classList.add('srt-loading'); localStorage.setItem('srt_pref_currency', currency); document.cookie = "srt_currency=" + currency + ";max-age=2592000;path=/"; syncDisplayPrices(); // Reload to ensure all server-side meta logic also aligns setTimeout(() => { location.reload(true); }, 150); } document.addEventListener('DOMContentLoaded', () => { // Initial Sync syncDisplayPrices(); // THE DOUBLE-SYNC HAMMER: Re-sync at intervals to catch any delayed/filtered content [100, 300, 600, 1200, 2500].forEach(delay => { setTimeout(syncDisplayPrices, delay); }); // Global Mutation Observer to catch any dynamic DOM changes const observer = new MutationObserver((mutations) => { let shouldSync = false; mutations.forEach(m => { if (m.addedNodes.length > 0 || m.type === 'attributes') { shouldSync = true; } }); if (shouldSync) syncDisplayPrices(); }); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); // Mobile menu toggle const btn = document.getElementById('mobile-menu-button'); const menu = document.getElementById('mobile-menu'); if (btn && menu) { btn.onclick = (e) => { e.stopPropagation(); menu.classList.toggle('hidden'); }; document.addEventListener('click', (e) => { if (!menu.contains(e.target) && !btn.contains(e.target)) { menu.classList.add('hidden'); } }); } });

activities