/* Add custom JS code below */ window.addEventListener('load', function () { const currencyFlags = { SAR: 'https://upload.wikimedia.org/wikipedia/commons/0/0d/Flag_of_Saudi_Arabia.svg', USD: 'https://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg', OMR: 'https://upload.wikimedia.org/wikipedia/commons/d/dd/Flag_of_Oman.svg', KWD: 'https://upload.wikimedia.org/wikipedia/commons/a/aa/Flag_of_Kuwait.svg', AED: 'https://upload.wikimedia.org/wikipedia/commons/c/cb/Flag_of_the_United_Arab_Emirates.svg', BHD: 'https://upload.wikimedia.org/wikipedia/commons/2/2c/Flag_of_Bahrain.svg', QAR: 'https://upload.wikimedia.org/wikipedia/commons/6/65/Flag_of_Qatar.svg' }; const btn = document.querySelector('button[onclick*="localization::open"]'); const modal = document.querySelector('salla-localization-modal'); if (!btn || !modal) return; function renderFlag() { const currentCurrency = modal.getAttribute('currency') || 'SAR'; const flag = currencyFlags[currentCurrency] || currencyFlags.SAR; btn.innerHTML = ` ⌄ `; } renderFlag(); // ارسم العلم أول مرة btn.style.background = 'transparent'; btn.style.border = '0'; btn.style.padding = '0'; btn.style.display = 'flex'; btn.style.alignItems = 'center'; btn.style.cursor = 'pointer'; // راقب أي تغيير على خاصية currency وأعد رسم العلم فورًا const observer = new MutationObserver(function (mutations) { mutations.forEach(function (m) { if (m.attributeName === 'currency') renderFlag(); }); }); observer.observe(modal, { attributes: true }); }); //footer (function () { "use strict"; function isEnglish() { const lang = (document.documentElement.lang || "").toLowerCase(); const path = location.pathname.toLowerCase(); return ( lang.indexOf("en") === 0 || path === "/en" || path.indexOf("/en/") === 0 ); } function addHajexoraStyle() { if (document.getElementById("hajexora-footer-style")) return; const style = document.createElement("style"); style.id = "hajexora-footer-style"; style.textContent = ` #hajexora-footer-link{ margin-top:6px; font-size:12px; line-height:1.8; text-align:inherit; } #hajexora-footer-link .hajexora-brand{ font-weight:700; text-decoration:none; background:linear-gradient(90deg,#3DD6E8 0%,#1565C0 100%); -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text; transition:opacity .25s ease; } #hajexora-footer-link .hajexora-brand:hover{ opacity:.75; } #hajexora-footer-link .hajexora-contact{ color:inherit; text-decoration:underline; text-underline-offset:2px; transition:opacity .25s ease; } #hajexora-footer-link .hajexora-contact:hover{ opacity:.7; } `; document.head.appendChild(style); } function addDeveloperFooter() { if (document.getElementById("hajexora-footer-link")) return; const rights = document.querySelector(".footer-rights p"); if (!rights) return; const isEn = isEnglish(); const hajexoraUrl = isEn ? "https://hajexora.com/en" : "https://hajexora.com/"; const element = document.createElement("div"); element.id = "hajexora-footer-link"; element.innerHTML = (isEn ? "Developed by " : "طور بواسطة ") + '' + (isEn ? "Hajexora" : "هاجكسورا") + "" + ' | ' + (isEn ? "Contact us" : "للتواصل") + ""; rights.appendChild(element); } function start() { addHajexoraStyle(); addDeveloperFooter(); const observer = new MutationObserver(function () { addDeveloperFooter(); }); observer.observe(document.body || document.documentElement, { childList: true, subtree: true }); } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", start); } else { start(); } })(); //منصة الاعمال الرقم (function () { 'use strict'; var CERTIFICATE_NUMBER = '0000337921'; var CERTIFICATE_URL = 'https://eauthenticate.saudibusiness.gov.sa/certificate-details/' + CERTIFICATE_NUMBER; var updateTimer = null; function isEnglish() { var html = document.documentElement; var lang = (html.getAttribute('lang') || '').toLowerCase(); var pathname = location.pathname.toLowerCase(); var search = location.search.toLowerCase(); return ( lang.indexOf('en') === 0 || pathname === '/en' || pathname.indexOf('/en/') === 0 || search.indexOf('lang=en') !== -1 || search.indexOf('locale=en') !== -1 ); } function getMessages() { if (isEnglish()) { return { number: 'Certificate No.: ' + CERTIFICATE_NUMBER, copy: 'Click to copy the number', copied: 'Number copied ✓' }; } return { number: 'رقم الشهادة: ' + CERTIFICATE_NUMBER, copy: 'اضغط لنسخ الرقم', copied: 'تم نسخ الرقم ✓' }; } function addCertificateNumber() { var link = document.querySelector( 'a[data-selia="footer-sbc-link"]' ); if (!link) return; var container = link.querySelector('.sbc-certificate-number'); if (!container) { container = document.createElement('span'); container.className = 'sbc-certificate-number'; container.innerHTML = '' + ''; container.style.cssText = 'display:flex!important;' + 'flex-direction:column!important;' + 'align-items:center!important;' + 'justify-content:center!important;' + 'margin-top:6px!important;' + 'font-family:inherit!important;' + 'text-align:center!important;' + 'cursor:pointer!important;' + 'direction:inherit!important;'; var numberText = container.querySelector('.sbc-number-text'); var copyMessage = container.querySelector('.sbc-copy-message'); numberText.style.cssText = 'display:block!important;' + 'font-size:13px!important;' + 'font-weight:700!important;' + 'line-height:1.5!important;' + 'color:inherit!important;'; copyMessage.style.cssText = 'display:block!important;' + 'margin-top:2px!important;' + 'font-size:11px!important;' + 'font-weight:400!important;' + 'line-height:1.5!important;' + 'color:inherit!important;' + 'opacity:.8!important;'; container.addEventListener('click', function (event) { event.preventDefault(); event.stopPropagation(); copyCertificateNumber(container); }); link.appendChild(container); } updateCertificateLanguage(container); } function updateCertificateLanguage(container) { if (!container) { container = document.querySelector( 'a[data-selia="footer-sbc-link"] .sbc-certificate-number' ); } if (!container) return; var messages = getMessages(); var numberText = container.querySelector('.sbc-number-text'); var copyMessage = container.querySelector('.sbc-copy-message'); container.setAttribute('lang', isEnglish() ? 'en' : 'ar'); container.setAttribute('dir', isEnglish() ? 'ltr' : 'rtl'); if (numberText && numberText.textContent !== messages.number) { numberText.textContent = messages.number; } if ( copyMessage && container.getAttribute('data-copying') !== 'true' && copyMessage.textContent !== messages.copy ) { copyMessage.textContent = messages.copy; } } function copyCertificateNumber(container) { if ( navigator.clipboard && navigator.clipboard.writeText && window.isSecureContext ) { navigator.clipboard.writeText(CERTIFICATE_NUMBER).then( function () { showCopiedMessage(container); }, function () { fallbackCopy(container); } ); } else { fallbackCopy(container); } } function fallbackCopy(container) { var textarea = document.createElement('textarea'); textarea.value = CERTIFICATE_NUMBER; textarea.setAttribute('readonly', ''); textarea.style.cssText = 'position:fixed;left:-9999px;top:0;opacity:0;'; document.body.appendChild(textarea); textarea.select(); textarea.setSelectionRange(0, textarea.value.length); try { document.execCommand('copy'); } catch (error) {} textarea.remove(); showCopiedMessage(container); } function showCopiedMessage(container) { var copyMessage = container.querySelector('.sbc-copy-message'); container.setAttribute('data-copying', 'true'); if (copyMessage) { copyMessage.textContent = getMessages().copied; } setTimeout(function () { window.open(CERTIFICATE_URL, '_blank', 'noopener'); container.removeAttribute('data-copying'); updateCertificateLanguage(container); }, 700); } function scheduleUpdate() { clearTimeout(updateTimer); updateTimer = setTimeout(function () { addCertificateNumber(); }, 100); } function start() { addCertificateNumber(); /* * يراقب ظهور الفوتر وتغيير لغة المتجر، * من دون تعديل زر اللغة أو تعطيل عمله. */ var observer = new MutationObserver(scheduleUpdate); observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ['lang', 'dir'] }); window.addEventListener('popstate', scheduleUpdate); document.addEventListener('click', function () { setTimeout(scheduleUpdate, 300); setTimeout(scheduleUpdate, 1000); }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', start, { once: true }); } else { start(); } })();