/* Add custom Js styles below */ document.querySelectorAll('.slide--cat-entry i').forEach((icon, index) => { const img = document.createElement('img'); img.className = 'cat-img'; // هنا غير الصور حسب الترتيب const images = [ 'https://i.postimg.cc/rpHT97V2/Group-1-1.png', 'https://i.postimg.cc/y88sfXXx/Group-2.png', 'https://i.postimg.cc/qMLpXZKW/Group-2-1.png', 'https://i.postimg.cc/CLYF8VRj/Group-2-2.png' ]; img.src = images[index]; img.alt = icon.nextElementSibling.innerText; icon.replaceWith(img); }); /*-------------------------*/ // البحث عن الكلاس المطلوب مع شرط وجود الصورة function initBannerSlider() { // التحقق من وجود السلايدر مسبقاً لمنع التكرار if (document.querySelector('.custom-banner-slider')) { console.log('السلايدر موجود مسبقاً'); return; } // البحث عن العنصر الذي يحتوي على الكلاسات المطلوبة const bannerElement = document.querySelector('.banner.banner--fixed.overflow-hidden'); if (!bannerElement) { console.log('لم يتم العثور على العنصر المطلوب'); return; } // التحقق من وجود الصورة المحددة const targetImageUrl = 'https://cdn.salla.sa/form-builder/gFdQxYTNFeNGFbtwU7MTrZtZ9EicsCq2VZBfxIBI.webp'; const images = bannerElement.querySelectorAll('img'); let hasTargetImage = false; images.forEach(img => { if (img.src === targetImageUrl) { hasTargetImage = true; } }); if (!hasTargetImage) { console.log('لم يتم العثور على الصورة المطلوبة'); return; } // إخفاء البنر الأصلي bannerElement.style.display = 'none'; // صور السلايدر const sliderImages = [ 'https://i.postimg.cc/9FpV60h6/g-Fd-Qx-YTNFe-NGFbtw-U7-MTr-Zt-Z9-Eics-Cq2-VZBfx-IBI.webp', 'https://i.postimg.cc/MKxq3Rh0/g4-Bn6-YSw-R5x-U7-A19-Rvdfgkoe8f-Tag1pet3-Prv-Pyy.webp', 'https://i.postimg.cc/HWbTt3Ps/0m-Fj-Vo-Dgd-XYlo-D214r-Bw7-QRPJ3-A7tp-ETEJp-CS3-CM.webp', 'https://i.postimg.cc/Hn0Hss77/I1-Wx-OZMqbd-Y3-NAa9-Psmve-G9-Ns-AAXhx-OZo-RWIJn-W8.webp' ]; // إنشاء CSS للسلايدر const sliderCSS = ` `; // إضافة CSS إلى الـ head document.head.insertAdjacentHTML('beforeend', sliderCSS); // إنشاء HTML للسلايدر const sliderHTML = `
`; // إدراج السلايدر في مكان البنر الأصلي bannerElement.insertAdjacentHTML('afterend', sliderHTML); // متغيرات السلايدر let currentSlide = 0; const totalSlides = sliderImages.length; // وظائف التحكم في السلايدر window.customSliderNext = function() { currentSlide = (currentSlide + 1) % totalSlides; updateSlider(); }; window.customSliderPrev = function() { currentSlide = (currentSlide - 1 + totalSlides) % totalSlides; updateSlider(); }; window.customSliderGoTo = function(index) { currentSlide = index; updateSlider(); }; function updateSlider() { const slides = document.querySelectorAll('.custom-slide'); const dots = document.querySelectorAll('.custom-dot'); slides.forEach((slide, index) => { slide.classList.toggle('active', index === currentSlide); }); dots.forEach((dot, index) => { dot.classList.toggle('active', index === currentSlide); }); } // تشغيل تلقائي للسلايدر setInterval(() => { window.customSliderNext(); }, 5000); // كل 5 ثواني console.log('تم إنشاء السلايدر بنجاح!'); } // منع التكرار باستخدام متغير عام window.customSliderInitialized = window.customSliderInitialized || false; // تشغيل السكريبت عند تحميل الصفحة if (!window.customSliderInitialized) { if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function() { if (!window.customSliderInitialized) { initBannerSlider(); window.customSliderInitialized = true; } }); } else { initBannerSlider(); window.customSliderInitialized = true; } // تشغيل السكريبت أيضاً في حالة تحميل محتوى ديناميكي (مرة واحدة فقط) setTimeout(function() { if (!window.customSliderInitialized) { initBannerSlider(); window.customSliderInitialized = true; } }, 1000); }