/* Add custom Js styles below */ document.addEventListener("DOMContentLoaded", function () { const form = document.querySelector(".product-form"); if (!form) return; let soldSection = form.querySelector(".is-sold.details"); let finalValue = 0; /* ====== قراءة العدد الحالي ====== */ if (soldSection) { const el = soldSection.querySelector(".sold-count"); if (el) { let current = parseInt(el.textContent.trim(), 10) || 0; if (current > 0) { finalValue = current + 200; // شرطك } } } /* ====== لو مفيش عنصر ====== */ if (!soldSection) { finalValue = Math.floor(Math.random() * (200 - 100 + 1)) + 50; soldSection = document.createElement("section"); soldSection.className = "is-sold details"; soldSection.innerHTML = `
عدد مرات الشراء
0
`; const installment = form.querySelector("salla-installment"); if (installment) { installment.insertAdjacentElement("afterend", soldSection); } else { form.prepend(soldSection); } } const counterEl = soldSection.querySelector(".sold-count"); /* ====== أنيميشن العداد ====== */ let start = 0; let duration = 1500; // مدة الأنيميشن (1.5 ثانية) let startTime = null; function animateCounter(timestamp) { if (!startTime) startTime = timestamp; let progress = timestamp - startTime; let value = Math.min( Math.floor((progress / duration) * finalValue), finalValue ); counterEl.textContent = value; if (value < finalValue) { requestAnimationFrame(animateCounter); } else { counterEl.textContent = finalValue; } } requestAnimationFrame(animateCounter); }); document.addEventListener("DOMContentLoaded", function () { const footer = document.querySelector("footer"); // الفوتر if (footer) { const credit = document.createElement("div"); credit.style.textAlign = "center"; credit.style.marginTop = "15px"; credit.style.fontSize = "13px"; credit.innerHTML = ` Made with ❤ WIZFREELANCE `; footer.appendChild(credit); credit.parentElement.style.backgroundColor = "var(--bottom-footer-bg)"; } }); // (() => { // const STORAGE_KEY = "yearEndOfferShown"; // if (sessionStorage.getItem(STORAGE_KEY)) return; // document.addEventListener("DOMContentLoaded", () => { // sessionStorage.setItem(STORAGE_KEY, "1"); // const overlay = document.createElement("div"); // overlay.style.cssText = ` // position: fixed; // inset: 0; // background: rgba(0,0,0,.6); // display: flex; // align-items: center; // justify-content: center; // z-index: 999999; // `; // const box = document.createElement("div"); // box.style.cssText = ` // position: relative; // background: transparent; // padding: 0; // border-radius: 14px; // box-shadow: 0 10px 30px rgba(0,0,0,.3); // max-width: 90%; // `; // // صورة الإعلان // const img = document.createElement("img"); // img.src = "https://cdn.files.salla.network/homepage/371453160/3a911703-2708-4207-b25e-e628ae792ec8.webp"; // img.alt = "عرض النضارة الكاملة"; // img.style.cssText = ` // display: block; // width: 100%; // max-width: 400px; // height: auto; // border-radius: 14px; // cursor: pointer; // `; // // 🔥 هنا الإضافة: عند الضغط يتم التحويل // img.addEventListener("click", () => { // window.location.href = "https://nurivasa.com/%D9%83%D8%B1%D9%8A%D9%85-%D8%B3%D9%8A%D8%B1%D9%8A%D9%86%D9%8A%D8%AA%D8%A7%D8%B3-%D8%A7%D9%84%D9%85%D8%B7%D9%88%D8%B1-3-%D9%82%D8%B7%D8%B9/p560715595"; // }); // const closeBtn = document.createElement("button"); // closeBtn.type = "button"; // closeBtn.textContent = "×"; // closeBtn.setAttribute("aria-label", "إغلاق"); // closeBtn.style.cssText = ` // position: absolute; // top: -14px; // right: -14px; // width: 32px; // height: 32px; // border: none; // border-radius: 50%; // background: var(--color-primary); // color: #fff; // font-size: 22px; // line-height: 32px; // cursor: pointer; // z-index: 10; // `; // const removePopup = () => overlay.remove(); // closeBtn.addEventListener("click", removePopup); // overlay.addEventListener("click", e => { // if (e.target === overlay) removePopup(); // }); // box.appendChild(closeBtn); // box.appendChild(img); // overlay.appendChild(box); // document.body.appendChild(overlay); // }); // })(); function playOnlyOne(el, id) { const modal = document.getElementById("videoModal"); const frame = document.getElementById("videoFrame"); // تشغيل الفيديو frame.src = `https://www.youtube.com/embed/${id}?autoplay=1`; // إظهار البوب اب modal.style.display = "flex"; // منع السكرول بدون تغيير موقع الصفحة document.body.style.overflow = "hidden"; } function closeVideo() { const modal = document.getElementById("videoModal"); const frame = document.getElementById("videoFrame"); // إخفاء البوب اب modal.style.display = "none"; frame.src = ""; // إعادة إمكانية السكرول document.body.style.overflow = ""; } /* قفل عند الضغط خارج الفيديو */ window.addEventListener("click", function(e){ const modal = document.getElementById("videoModal"); if(e.target === modal){ closeVideo(); } }); const words = ["الأجمل", "الأفضل", "تستحقين"]; let index = 0; function startTextAnimation() { const wordElement = document.querySelector(".changing-word"); if (!wordElement) { setTimeout(startTextAnimation, 500); return; } function changeWord() { wordElement.style.opacity = 0; setTimeout(() => { index = (index + 1) % words.length; wordElement.textContent = words[index]; wordElement.style.opacity = 1; // لو آخر كلمة → مدة أطول let delay = (index === words.length - 1) ? 4000 : 2000; setTimeout(changeWord, delay); }, 300); } changeWord(); } startTextAnimation();