function setLang(lang) { let select = document.querySelector(".cloudlocalization-selection"); if (!select) return; let option = select.querySelector(`option[value="${lang}"]`); if (!option) return; select.value = lang; select.dispatchEvent(new Event("input", { bubbles: true })); select.dispatchEvent(new Event("change", { bubbles: true })); } function setCurrency(currency) { let select = document.querySelector(".currency-w"); if (!select) return; let option = select.querySelector(`option[value="${currency}"]`); if (!option) return; select.value = currency; select.dispatchEvent(new Event("input", { bubbles: true })); select.dispatchEvent(new Event("change", { bubbles: true })); } // Save choice + apply settings function setLangCurrency(lang, currency) { setLang(lang); setCurrency(currency); localStorage.setItem("site_lang", lang); localStorage.setItem("site_currency", currency); localStorage.setItem("region_select", true); } window.addEventListener("DOMContentLoaded", () => { const popup = document.getElementById("country-popup"); let savedLang = localStorage.getItem("site_lang"); let savedCurrency = localStorage.getItem("site_currency"); let region_select = localStorage.getItem("region_select"); if (savedLang && savedCurrency && region_select) { // Already chosen → apply and do not show popup again setLangCurrency(savedLang, savedCurrency); popup.style.display = "none"; } else { // First time → show popup popup.style.display = "flex"; } // Button events document.querySelector(".vn-option").addEventListener("click", () => { setLangCurrency("vi", "vnd"); // uppercase matches your