/* Add custom Js code below const div= document.createElement('div'); div.classList.add('watsapp'); div.style='position: fixed;z-index: 11111111111;width: 55px; bottom: 80px;height: 100px;right: 30px;' div.innerHTML=` `; document.body.appendChild(div);*/ (function () { const API_URL = "https://live-gold-development-1ce6929338ed.herokuapp.com/api/metals"; const API_HEADERS = { "Content-Type": "application/json;charset=utf-8", "X-API-KEY": "sv5xalf3ms3rk7nv24bqywcc8b72an5x" }; const REFRESH_MS = 45_000; // ========== UI Parts ========== const upSvg = ''; const downSvg = ''; const fmt = (n, digits=2) => Number(n).toLocaleString("en-US", { minimumFractionDigits: digits, maximumFractionDigits: digits }); function updatePrice(selector, value, status) { const el = document.querySelector(selector); if (el) el.textContent = fmt(value); const arrow = document.querySelector(selector + "-arrow"); if (arrow) arrow.innerHTML = status === "up" ? upSvg : status === "down" ? downSvg : ""; } // ========== Create Bar if Missing ========== function ensureBar() { if (document.querySelector(".pricesBar")) return; const css = ` .pricesBar{display:flex;justify-content:center;align-items:center;width:100vw;background:#000;color:#fff;padding:2px 0;position:fixed;top:0;z-index:1000} .pricesBar ul{display:flex;justify-content:space-around;width:100%;list-style:none;padding:0;margin:0;direction:ltr} .pricesBar ul li{text-align:center;font-size:14px;color:#fff;position:relative;padding:0 20px;flex:1} .label{display:block;font-size:14px;color:#fff} .price-container{display:flex;align-items:center;justify-content:center;gap:6px} .price{font-size:14px;font-weight:bold;color:#debc5b} .currency{font-size:12px;color:#debc5b} .arrow-icon{width:22px;height:22px} .pricesBar ul li::after{content:"";height:100%;width:.25px;background:#debc5b;position:absolute;right:0;top:0} .pricesBar ul li:last-child::after{display:none} @media (max-width:768px){ .pricesBar ul{flex-direction:column;align-items:center} .pricesBar ul li{display:none;width:100%;margin-bottom:10px} .pricesBar ul li.gold-24k-item{display:block;font-size:16px;margin-top:0;position:relative} .pricesBar ul li.gold-24k-item::before{content:"▼";position:absolute;left:35px;top:50%;transform:translateY(-50%);font-size:12px;color:#debc5b;transition:transform .3s ease} .pricesBar ul li.show{display:block} .pricesBar ul li.gold-24k-item.expanded::before{transform:translateY(-50%) rotate(180deg)} .pricesBar ul li .divi{display:flex!important;font-size:16px;justify-content:space-around!important;flex-direction:row-reverse!important} }`; const st = document.createElement("style"); st.textContent = css; document.head.appendChild(st); const bar = document.createElement("div"); bar.className = "pricesBar"; bar.innerHTML = ` `; document.body.prepend(bar); // Mobile toggle bar.querySelector(".gold-24k-item")?.addEventListener("click", function () { const listItems = bar.querySelectorAll(".pricesBar ul li"); const isOpen = Array.from(listItems).some(li => !li.classList.contains("gold-24k-item") && li.classList.contains("show")); listItems.forEach(li => { if (!li.classList.contains("gold-24k-item")) { isOpen ? li.classList.remove("show") : li.classList.add("show"); } }); this.classList.toggle("expanded", !isOpen); }); } // ========== Fetch & Update ========== async function getPrices() { try { const res = await fetch(API_URL, { method: "GET", headers: API_HEADERS }); if (!res.ok) throw new Error("Network error " + res.statusText); const data = await res.json(); // ريال/جرام updatePrice(".gold-24k", data.gold.priceGram24k.value, data.gold.priceGram24k.status); updatePrice(".gold-22k", data.gold.priceGram22k.value, data.gold.priceGram22k.status); updatePrice(".gold-21k", data.gold.priceGram21k.value, data.gold.priceGram21k.status); updatePrice(".gold-18k", data.gold.priceGram18k.value, data.gold.priceGram18k.status); } catch (e) { console.error("Error fetching prices:", e); } } // ========== Init ========== ensureBar(); getPrices(); setInterval(getPrices, REFRESH_MS); })(); (function () { function insertVideoBeforeBanner() { const anchor = document.querySelector('section#EF_banner_sec_5'); if (!anchor) { return; } // Avoid duplicating if already added if (document.getElementById('EF_video_banner')) return; // Build the section const section = document.createElement('section'); section.id = 'EF_video_banner'; section.style.margin = '0'; // Build the video const video = document.createElement('video'); video.src = 'https://gold-seahorse-682738.hostingersite.com/banner-gif-adyar.mp4'; video.autoplay = true; video.loop = true; video.muted = true; // required for autoplay video.playsInline = true; // iOS Safari support video.setAttribute('playsinline', ''); video.setAttribute('webkit-playsinline', ''); video.preload = 'auto'; video.style.width = '100%'; video.style.height = 'auto'; video.setAttribute('aria-label', 'Intro video'); section.appendChild(video); // Insert before the target section anchor.parentNode.insertBefore(section, anchor); } // Run safely whether DOM is ready or already loaded if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', insertVideoBeforeBanner, { once: true }); } else { insertVideoBeforeBanner(); } })();