/* 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 = `
`;
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 = "sallaDiscountsOfferShown";
// if (sessionStorage.getItem(STORAGE_KEY)) return;
// document.addEventListener("DOMContentLoaded", () => {
// sessionStorage.setItem(STORAGE_KEY, "1");
// // 1. إنشاء الطبقة الخلفية
// const overlay = document.createElement("div");
// overlay.style.cssText = `
// position: fixed;
// inset: 0;
// background: rgba(0,0,0,.7);
// display: flex;
// align-items: center;
// justify-content: center;
// z-index: 999999;
// padding: 15px;
// `;
// // 2. كود الـ CSS للأنيميشن والتجاوب
// const styleSheet = document.createElement("style");
// styleSheet.innerText = `
// @keyframes pulseGold {
// 0% { transform: scale(1); }
// 50% { transform: scale(1.08); color: #d4af37; }
// 100% { transform: scale(1); }
// }
// @keyframes fadeInScale {
// from { opacity: 0; transform: scale(0.9); }
// to { opacity: 1; transform: scale(1); }
// }
// .golden-guarantee {
// display: inline-block;
// font-weight: bold;
// color: #b8860b;
// margin-bottom: 15px;
// font-size: 1.2rem;
// animation: pulseGold 1.5s infinite ease-in-out;
// }
// @media (max-width: 600px) {
// .popup-flex-container { flex-direction: column-reverse !important; height: auto !important; }
// .popup-image-side { width: 100% !important; min-height: 400px !important; }
// .popup-text-side { padding: 25px 20px !important; }
// }
// `;
// document.head.appendChild(styleSheet);
// // 3. حاوية المحتوى
// const box = document.createElement("div");
// box.classList.add('popup-flex-container');
// box.style.cssText = `
// position: relative;
// background: #fff;
// border-radius: 20px;
// overflow: hidden;
// max-width: 750px;
// width: 100%;
// display: flex;
// flex-direction: row-reverse;
// box-shadow: 0 20px 40px rgba(0,0,0,0.4);
// animation: fadeInScale 0.4s ease-out;
// `;
// // 4. الجزء الخاص بالنصوص (اليمين)
// const textSide = document.createElement("div");
// textSide.classList.add('popup-text-side');
// textSide.style.cssText = `
// flex: 1;
// padding: 40px 30px;
// text-align: center;
// display: flex;
// flex-direction: column;
// justify-content: center;
// direction: rtl;
// `;
// textSide.innerHTML = `
// ✨ ضمان ذهبي ✨
//
// خصومات السلة بدأت
تصل إلى 15%
//
//
//
مفاجأة قوية لعملائنا
//
الآن تقدر توفر أكثر على كل طلباتك
//
//
// `;
// // 5. الجزء الخاص بالصورة الجديدة (اليسار)
// const imageSide = document.createElement("div");
// imageSide.classList.add('popup-image-side');
// imageSide.style.cssText = `
// width: 45%;
// background: url('https://cdn.files.salla.network/homepage/371453160/e2f89a47-03e0-4789-8159-b143a8adab3b.webp') center/cover;
// min-height: 380 px;
// `;
// // 6. زر الإغلاق
// const closeBtn = document.createElement("button");
// closeBtn.innerHTML = "×";
// closeBtn.style.cssText = `
// position: absolute;
// top: 12px;
// right: 12px;
// width: 34px;
// height: 34px;
// border: none;
// background: rgba(0,0,0,0.05);
// border-radius: 50%;
// font-size: 28px;
// line-height: 34px;
// cursor: pointer;
// z-index: 11;
// color: #777;
// `;
// const removePopup = () => overlay.remove();
// closeBtn.addEventListener("click", removePopup);
// overlay.addEventListener("click", e => { if (e.target === overlay) removePopup(); });
// // التجميع النهائي
// box.appendChild(closeBtn);
// box.appendChild(textSide);
// box.appendChild(imageSide);
// overlay.appendChild(box);
// document.body.appendChild(overlay);
// });
// })();
// (() => {
// 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/e2f89a47-03e0-4789-8159-b143a8adab3b.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/%D8%A7%D9%84%D8%A3%D9%83%D8%AB%D8%B1-%D8%B7%D9%84%D8%A8%D8%A7/c1582243573?filters[category_id]=1582243573";
// });
// 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);
// });
// })();
// (() => {
// 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;
// padding: 15px;
// `;
// const box = document.createElement("div");
// box.style.cssText = `
// position: relative;
// background: transparent;
// padding: 0;
// border-radius: 14px;
// max-width: 90%;
// `;
// // رابط الصورة
// const link = document.createElement("a");
// link.href =
// "https://nurivasa.com/%D8%B1%D9%88%D8%AA%D9%8A%D9%86-%D9%81%D8%B1%D9%82-%D9%88%D8%A7%D8%B6%D8%AD-%D9%84%D9%84%D8%A7%D8%B4%D8%B1%D8%A7%D9%82%D9%87-%D9%88%D9%85%D9%83%D8%A7%D9%81%D8%AD%D8%A9-%D8%A7%D9%84%D8%AA%D8%AC%D8%A7%D8%B9%D9%8A%D8%AF-_-%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-+-%D9%83%D8%B1%D9%8A%D9%85-%D8%A3%D9%88%D8%B1%D9%88%D8%B1/p1773405543";
// link.target = "_self";
// link.style.display = "block";
// // صورة الإعلان
// const img = document.createElement("img");
// img.src =
// "https://cdn.files.salla.network/other/371453160/147f6ab0-4bbb-4eb2-a357-178fcda1e4f7-original.webp";
// img.alt = "عرض النضارة الكاملة";
// img.style.cssText = `
// display: block;
// width: 100%;
// max-width: 400px;
// height: auto;
// border-radius: 14px;
// cursor: pointer;
// box-shadow: 0 10px 30px rgba(0,0,0,.3);
// `;
// // زر الإغلاق
// 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();
// });
// // تركيب العناصر
// link.appendChild(img);
// box.appendChild(closeBtn);
// box.appendChild(link);
// overlay.appendChild(box);
// document.body.appendChild(overlay);
// });
// })();
(() => {
const STORAGE_KEY = "yearEndOfferShown";
// التحقق المباشر: هل شاهد العميل/أغلق العرض من قبل؟
const isAlreadyDismissed = localStorage.getItem(STORAGE_KEY) === "1";
document.addEventListener("DOMContentLoaded", () => {
// 1. إنشاء النافذة المنبثقة (Pop-up)
const overlay = document.createElement("div");
overlay.style.cssText = `
position: fixed;
inset: 0;
background: rgba(0,0,0,.6);
display: none; /* يظل مخفياً حتى ينتهي المؤقت */
align-items: center;
justify-content: center;
z-index: 999999;
padding: 15px;
`;
const box = document.createElement("div");
box.style.cssText = `
position: relative;
background: transparent;
padding: 0;
border-radius: 14px;
max-width: 90%;
`;
// رابط الصورة
const link = document.createElement("a");
link.href =
"https://nurivasa.com/%D8%B1%D9%88%D8%AA%D9%8A%D9%86-%D9%81%D8%B1%D9%82-%D9%88%D8%A7%D8%B6%D8%AD-%D9%84%D9%84%D8%A7%D8%B4%D8%B1%D8%A7%D9%82%D9%87-%D9%88%D9%85%D9%83%D8%A7%D9%81%D8%AD%D8%A9-%D8%A7%D9%84%D8%AA%D8%AC%D8%A7%D8%B9%D9%8A%D8%AF-_-%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-+-%D9%83%D8%B1%D9%8A%D9%85-%D8%A3%D9%88%D8%B1%D9%88%D8%B1/p1773405543";
link.target = "_self";
link.style.display = "block";
// صورة الإعلان
const img = document.createElement("img");
img.src =
"https://cdn.files.salla.network/other/371453160/4e481942-261c-4efd-8346-d69cefd69c80-original.webp";
img.alt = "عرض النضارة الكاملة";
img.style.cssText = `
display: block;
width: 100%;
max-width: 400px;
height: auto;
border-radius: 14px;
cursor: pointer;
box-shadow: 0 10px 30px rgba(0,0,0,.3);
`;
// زر الإغلاق داخل البوب أب
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, #265511);
color: #fff;
font-size: 22px;
line-height: 32px;
cursor: pointer;
z-index: 10;
`;
// 2. إنشاء الشريط الجانبي (Side Strip)
const stripBtn = document.createElement("button");
stripBtn.id = "selia-discount-strip";
stripBtn.className = "selia-discount-strip selia-discount-strip--right";
stripBtn.setAttribute("aria-label", "عروض اليوم الوطني");
stripBtn.innerHTML = `عرض اليوم الوطني`;
stripBtn.style.cssText = `
position: fixed;
right: 0;
top: 50%;
transform: translateY(-50%) rotate(-90deg);
transform-origin: right bottom;
background-color: var(--color-primary);
color: #f9f9f0;
border: none;
padding: 8px 16px;
font-size: 14px;
font-weight: bold;
border-radius: 8px 8px 0 0;
cursor: pointer;
z-index: 999998;
box-shadow: -2px 0 8px rgba(0,0,0,0.2);
display: ${isAlreadyDismissed ? "block" : "none"};
`;
// دالة الإغلاق (تثبيت عدم الظهور التلقائي مستقبلاً في localStorage)
const hidePopup = () => {
overlay.style.display = "none";
stripBtn.style.display = "block";
localStorage.setItem(STORAGE_KEY, "1");
};
// دالة الفتح اليدوي عند الضغط على الشريط فقط
const showPopup = () => {
overlay.style.display = "flex";
stripBtn.style.display = "none";
};
closeBtn.addEventListener("click", hidePopup);
overlay.addEventListener("click", e => {
if (e.target === overlay) hidePopup();
});
stripBtn.addEventListener("click", showPopup);
// تركيب العناصر
link.appendChild(img);
box.appendChild(closeBtn);
box.appendChild(link);
overlay.appendChild(box);
document.body.appendChild(overlay);
document.body.appendChild(stripBtn);
// 3. تطبيق تأخير 3 ثوانٍ للزيارة الأولى فقط
if (!isAlreadyDismissed) {
setTimeout(() => {
// التأكد من أن العميل لم يغلق العرض خلال وقت التأخير قبل الإظهار
if (localStorage.getItem(STORAGE_KEY) !== "1") {
overlay.style.display = "flex";
}
}, 3000); // 3000 ملّي ثانية = 3 ثوانٍ
}
});
})();
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();
(function () {
// 1. مصفوفة تحتوي على معرفات (IDs) المنتجات المستهدفة
const targetProductIds = ['1773405543'];
// 2. التحقق مما إذا كانت الصفحة الحالية تحتوي على أي من معرفات المنتجات (سواء في الرابط أو في عناصر الصفحة)
const currentUrl = window.location.href;
const isTargetPage = targetProductIds.some(id =>
currentUrl.includes(id) || document.querySelector(`.product-${id}`) !== null
);
// إذا لم تكن من الصفحات المستهدفة، يخرج السكريبت فوراً
if (!isTargetPage) return;
// 3. كود البانر الخاص بك
const bannerHTML = `
هذا المنتج عليه طلب كبير✨
سارع في الطلب قبل
03:52
لضمان توفير المنتج
`;
// 4. دالة العداد التنازلي
function startTimer(duration) {
let timer = duration;
const timerElement = document.getElementById("s-timer");
if (!timerElement) return;
setInterval(function () {
let minutes = Math.floor(timer / 60);
let seconds = timer % 60;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
timerElement.textContent = minutes + ":" + seconds;
if (--timer < 0) {
timer = duration;
}
}, 1000);
}
// 5. البحث عن وسم salla-installment وإدراجه
let attempts = 0;
const maxAttempts = 30; // محاولة لمدة 6 ثوانٍ
const checkExist = setInterval(function () {
attempts++;
const sallaTag = document.querySelector('salla-installment');
if (sallaTag) {
if (!document.getElementById('custom-demand-banner')) {
sallaTag.insertAdjacentHTML('afterend', bannerHTML);
startTimer(232); // 3 دقائق و 52 ثانية
}
clearInterval(checkExist);
} else if (attempts >= maxAttempts) {
clearInterval(checkExist);
}
}, 200);
})();
(function () {
'use strict';
const BOX_ID = 'custom-product-prices';
const STYLE_ID = 'custom-discount-glow-styles';
// تحويل الأرقام العربية إلى إنجليزية واستخراج الرقم
function parseToNumber(str) {
if (!str) return 0;
const arabicDigits = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
let englishStr = String(str);
for (let i = 0; i < 10; i++) {
englishStr = englishStr.replace(new RegExp(arabicDigits[i], 'g'), i);
}
return parseFloat(englishStr.replace(/[^0-9.]/g, '')) || 0;
}
// تنسيق الأرقام بالإنجليزي
function formatNumber(number) {
return Math.round(number).toLocaleString('en-US');
}
// حقن استايلات البوردر المضيء والحركات
function injectStyles() {
if (document.getElementById(STYLE_ID)) return;
const style = document.createElement('style');
style.id = STYLE_ID;
style.textContent = `
@keyframes pulseGlowGreen {
0% {
border-color: rgba(34, 197, 94, 0.4);
box-shadow: 0 0 6px rgba(34, 197, 94, 0.2), inset 0 0 4px rgba(34, 197, 94, 0.1);
}
50% {
border-color: rgba(34, 197, 94, 0.9);
box-shadow: 0 0 14px rgba(34, 197, 94, 0.5), inset 0 0 8px rgba(34, 197, 94, 0.2);
}
100% {
border-color: rgba(34, 197, 94, 0.4);
box-shadow: 0 0 6px rgba(34, 197, 94, 0.2), inset 0 0 4px rgba(34, 197, 94, 0.1);
}
}
@keyframes pulseGlowRed {
0% {
border-color: rgba(239, 68, 68, 0.4);
box-shadow: 0 0 6px rgba(239, 68, 68, 0.2), inset 0 0 4px rgba(239, 68, 68, 0.1);
}
50% {
border-color: rgba(239, 68, 68, 0.9);
box-shadow: 0 0 14px rgba(239, 68, 68, 0.5), inset 0 0 8px rgba(239, 68, 68, 0.2);
}
100% {
border-color: rgba(239, 68, 68, 0.4);
box-shadow: 0 0 6px rgba(239, 68, 68, 0.2), inset 0 0 4px rgba(239, 68, 68, 0.1);
}
}
.glow-card-green {
border: 1.5px solid rgba(34, 197, 94, 0.5) !important;
animation: pulseGlowGreen 2.5s infinite ease-in-out;
transition: transform 0.2s ease;
}
.glow-card-red {
border: 1.5px solid rgba(239, 68, 68, 0.5) !important;
animation: pulseGlowRed 2.5s infinite ease-in-out;
transition: transform 0.2s ease;
}
.glow-card-green:hover, .glow-card-red:hover {
transform: translateY(-1px);
}
`;
document.head.appendChild(style);
}
function initCustomPriceDiscount() {
if (document.getElementById(BOX_ID)) return;
// تم التحديث ليطابق الكلاس الجديد .price بدلاً من .product-price.product-price-bottom
const priceSection = document.querySelector('.price');
if (!priceSection) return;
const salePriceElem = priceSection.querySelector('.price_is_on_sale .total-price');
const beforePriceElem = priceSection.querySelector('.price_is_on_sale .before-price');
if (!salePriceElem || !beforePriceElem) return;
const salePrice = parseToNumber(salePriceElem.textContent);
const beforePrice = parseToNumber(beforePriceElem.textContent);
if (!salePrice || !beforePrice || beforePrice <= salePrice) return;
const saveAmount = Math.round(beforePrice - salePrice);
const discountPercent = Math.round(((beforePrice - salePrice) / beforePrice) * 100);
if (saveAmount <= 0 || discountPercent <= 0) return;
// حقن CSS الوهّاج
injectStyles();
const bannerHTML = `
وفر ${formatNumber(saveAmount)}
خصم ${formatNumber(discountPercent)}%
`;
priceSection.insertAdjacentHTML('afterend', bannerHTML);
}
let attempts = 0;
const interval = setInterval(function () {
attempts++;
// التعديل هنا للبحث داخل المجموعات المتاحة في الكود الجديد
const priceElement = document.querySelector('.price .price_is_on_sale');
if (priceElement) {
initCustomPriceDiscount();
clearInterval(interval);
} else if (attempts >= 30) {
clearInterval(interval);
}
}, 200);
})();