/* ========================================================================== ألوان العالم | Alwan Al-alem — تخصيص متقدم (JavaScript) متجر قطع غيار Range Rover و Jaguar — ثيم رائد (Raed) — منصة سلة ========================================================================== */ const rangeRoverLogo = "https://cdn.phototourl.com/free/2026-07-26-51c0bb58-3a11-45f4-9962-67a9b8a5a475.png"; const jaguarLogo = "https://cdn.phototourl.com/free/2026-07-26-29449aad-fa1f-4d17-9ddf-70b0ecf27df5.png"; document.addEventListener('DOMContentLoaded', function () { /* ------------------------------------------------------------------ 0) دالة مساعدة جديدة: التأكد أننا في الصفحة الرئيسية فقط نعتمد أولاً على واجهة سلة الرسمية salla.config.get('page.type') وهذه أدق طريقة لأنها لا تتأثر بالدومين المخصص أو المسارات الفرعية. في حال لم تكن salla.config متاحة بعد، نستخدم فحص المسار كخطة بديلة. ------------------------------------------------------------------ */ function isHomePage() { try { if (window.salla && salla.config && typeof salla.config.get === 'function') { var pageType = salla.config.get('page.type'); if (pageType) { return pageType === 'index' || pageType === 'home'; } } } catch (e) { // نتجاهل الخطأ وننتقل للخطة البديلة } // خطة بديلة: التأكد أن المسار هو الجذر فقط (الصفحة الرئيسية) var path = window.location.pathname.replace(/\/+$/, ''); return path === '' || path === '/'; } function findFirst(selectors) { for (var i = 0; i < selectors.length; i++) { var el = document.querySelector(selectors[i]); if (el) return el; } return null; } function injectChooseCarSection() { var RANGE_ROVER_URL = '/رنج-روفر-range-rover/c1363028479'; var JAGUAR_URL = '/جاكوار-jaguar/c215268110'; var section = document.createElement('section'); section.id = 'aa-choose-car'; section.className = 'aa-fade-in'; section.innerHTML = '

اختر سيارتك

' + '
' + '' + '
' + '' + '
' + '
Range Rover
' + '
' + '' + '
' + '' + '
' + '
Jaguar
' + '
' + '
'; var heroBanner = findFirst([ '.s-block-slider', '#s-store-slider', '.s-home-slider', 'salla-slider' ]); if (heroBanner && heroBanner.parentNode) { heroBanner.parentNode.insertBefore(section, heroBanner.nextSibling); } else { var main = document.querySelector('main') || document.body; main.insertBefore(section, main.firstChild); } } function injectVinBanner() { var WHATSAPP_NUMBER = '966567717936'; var WHATSAPP_MESSAGE = encodeURIComponent('مرحبًا، أرغب في مساعدة لمعرفة رقم القطعة المناسب لسيارتي (رقم الهيكل VIN):'); var banner = document.createElement('div'); banner.id = 'aa-vin-banner'; banner.className = 'aa-fade-in'; banner.innerHTML = '

لا تعرف رقم القطعة؟

' + '

أرسل رقم الهيكل VIN وسنساعدك في اختيار القطعة المناسبة.

' + '' + 'تواصل عبر واتساب'; var latestProducts = document.querySelector('#aa-latest-products, .s-block-latest-products, .latest-products'); if (latestProducts && latestProducts.parentNode) { latestProducts.parentNode.insertBefore(banner, latestProducts); } else { var footer = document.querySelector('.s-footer, salla-footer, footer'); if (footer && footer.parentNode) { footer.parentNode.insertBefore(banner, footer); } else { document.body.appendChild(banner); } } } function initScrollReveal() { var targets = document.querySelectorAll( '.aa-fade-in, #aa-features .aa-feature-card, .s-product-card, salla-product-card' ); targets.forEach(function (el) { if (!el.classList.contains('aa-fade-in')) { el.classList.add('aa-fade-in'); } }); if (!('IntersectionObserver' in window)) { targets.forEach(function (el) { el.classList.add('aa-visible'); }); return; } var observer = new IntersectionObserver(function (entries) { entries.forEach(function (entry) { if (entry.isIntersecting) { entry.target.classList.add('aa-visible'); observer.unobserve(entry.target); } }); }, { threshold: 0.15 }); targets.forEach(function (el) { observer.observe(el); }); } function injectFeaturesSection() { var features = [ { icon: '✓', title: 'قطع أصلية وبديلة' }, { icon: '🚚', title: 'شحن سريع' }, { icon: '🛡️', title: 'ضمان جودة عالية ' }, { icon: '💬', title: 'دعم سريع عبر الواتساب اثناء اوقات الدوام الرسمي' }, { icon: '🏬', title: 'إمكانية الاستلام من الفروع خلال يوم عمل واحد من تاريخ الطلب' } ]; var section = document.createElement('section'); section.id = 'aa-features'; section.className = 'aa-fade-in'; var grid = document.createElement('div'); grid.className = 'aa-features-grid'; features.forEach(function (f) { var card = document.createElement('div'); card.className = 'aa-feature-card'; card.innerHTML = '
' + f.icon + '
' + '
' + f.title + '
'; grid.appendChild(card); }); section.appendChild(grid); var chooseCar = document.getElementById('aa-choose-car'); if (chooseCar && chooseCar.parentNode) { chooseCar.parentNode.insertBefore(section, chooseCar.nextSibling); } else { var main = document.querySelector('main') || document.body; main.appendChild(section); } } /* ------------------------------------------------------------------ تشغيل الأقسام الخاصة بالصفحة الرئيسية فقط ------------------------------------------------------------------ */ if (isHomePage()) { injectChooseCarSection(); injectFeaturesSection(); injectVinBanner(); } // الأنيميشن يبقى عامًا لكل الصفحات لأنه يعمل فقط على العناصر الموجودة فعلاً setTimeout(initScrollReveal, 300); });