const link = document.createElement("link"); link.rel = "stylesheet"; link.href = "https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Tajawal:wght@300;400;500;700&display=swap"; document.head.appendChild(link); const sleepTimeHeader = `
info@sleeptimesa.com
966555022973
شحن مجاني لجميع الطلبات
`; const sleepTimeFooter = ` `; const sleepTimeHomePage = `
سليب تايم مراتب

نوم أعمق
يبدأ من المرتبة
المناسبة

مراتب عالية الجودة مصممة لدعم راحتك ومنحك نومًا صحيًا كل ليلة.

توصيل مجاني

إلى جميع مناطق المملكة

دفع آمن

خيارات دفع متعددة وآمنة

صناعة سعودية

جودة محلية بمعايير عالمية

ضمان حتى 10 سنوات

جودة تدوم، راحة تدوم

تسوق حسب القسم

اللباد الفندقي
اللباد الفندقي
سرائر
سرائر
المراتب
المراتب

الأكثر مبيعاً

عرض جميع المراتب

تهوية مثالية

خامات تسمح بمرور الهواء وتحافظ على الانتعاش

دعم متوازن

تقنيات دعم عمودك الفقري لتقليل آلام الظهر

راحة تدوم

مواد عالية الجودة تضمن لك راحة طويلة الأمد

نوم صحي

مرتبتنا مصممة لتحسين جودة نومك كل ليلة

عملاؤنا يثقون بنا

10+
سنوات خبرة
50K+
عميل سعيد
25K+
طلب منفذ

المرتبة ممتازة والنوم صار أريح بكثير والتوصيل كان سريع جدًا.

أحمد العنيبي

جودة عالية وخدمة عملاء رائعة، أنصح الجميع بالتعامل معهم.

سارة الشهري

أفضل مرتبة جربتها على الإطلاق، الدعم والنوم مثالي.

محمد الحربي
`; // Render Home Page document.addEventListener("DOMContentLoaded", async () => { const path = window.location.pathname.replace(/\/$/, ""); const HOME_PATHS = ["", "/","/ar"]; const isHomePage = HOME_PATHS.includes(path); if (isHomePage) { renderHomePage(); const pageWrapper = document.querySelector(".page-wrapper"); if (pageWrapper) { pageWrapper.style.display = "none"; } } }); // Render Shared Components document.addEventListener("DOMContentLoaded", () => { const path = decodeURIComponent(window.location.pathname.replace(/\/$/, "")); const CATEGORY_PATHS = [ "/ar/مراتب/c2140815765", "/ar/سرير/c1272220227", "/ar/لباد-فندقي/c1538394436", "/ar/طبية/c308206442", "/ar/فندقية/c200095861", "/ar/الاكثر-مبيعا/c1182297727", "/ar/مفارش/c518504633", "/ar/شراشف/c1859043953", "/ar/بطانيات/c950788466", "/ar/أسرة/c766597204", "/ar/صمم-سريرك-مع-الفريق-المختص/c653110464", "/ar/سرير-مفرد/c1788604748", "/ar/سرير-مزدوج/c1147146317", "/ar/اكسسوارات/c1468822886", "/ar/معطرات-مفارش/c1022349799", "/ar/روب-استحمام/c374161230", "/ar/مخدات-طبية/c1505409866", "/ar/مخدات-فندقية/c91027796", "/ar/طاولة-بلوت/c2110040489", "/ar/من-نحن/page-844883963", // Cart "/ar/cart", // Static Pages "/ar/سياسية-الاستبدال-والاسترجاع/page-251159693", "/ar/شهادة-الايزو/page-424055582", "/ar/السجل-التجاري-متجر-sleep-time/page-1631253635", "/ar/الرقم-الضريبي-vta-متجر-sleep-time/page-856101772", "/ar/اختبار-النوم/page-1535506802", "/ar/كم-المدة-التي-يستغرقها-طلبي-في-الوصول-الي/page-35250531", "/ar/سياسة-الخصوصية/page-1326798358", "/ar/الشروط-والأحكام/page-1664493187", ]; const isProductPage = /\/p\d+$/.test(path); if (CATEGORY_PATHS.includes(path) || isProductPage) { renderSharedLayout(); const pageWrapper = document.querySelector(".page-wrapper"); if (pageWrapper) { pageWrapper.style.removeProperty("display"); } } if (isProductPage) { const suggestions = document.querySelector(".page-wrapper.bg-grey"); if (suggestions) { suggestions.style.display = "none"; } } }); function renderHomePage() { injectHomeHTML(); injectHomeCSS(); moveTabbyToHero(); getSallaCart(); mobileToggleButton(); getMattressProductsLength(); renderBestSellers(); } function injectHomeHTML() { if (document.getElementById("custom-home-wrapper")) return; const homeBlock = document.querySelector(".home-block"); if (homeBlock) { homeBlock.style.display = "none"; } // const pageWrapper = document.querySelector(".page-wrapper"); // if (pageWrapper) { // pageWrapper.style.display = "none"; // } const footer = document.querySelector("footer"); if (footer) { footer.style.display = "none"; } const hero = document.querySelector(".hero"); if (hero) { hero.style.display = "none"; } const topHeader = document.querySelector(".top-header"); if (topHeader) { topHeader.style.display = "none"; } const siteHeader = document.querySelector("#site-header-outer"); if (siteHeader) { siteHeader.style.position = "absolute"; siteHeader.style.top = "-999px"; } const stickyHeader = document.querySelector(".site-header"); if (stickyHeader) { stickyHeader.style.opacity = 0; } const wrapper = document.createElement("div"); wrapper.id = "custom-home-wrapper"; wrapper.innerHTML = ` ${sleepTimeHeader} ${sleepTimeHomePage} ${sleepTimeFooter} `; document.body.appendChild(wrapper); } function injectHomeCSS() { if (document.getElementById("custom-home-style")) return; const style = document.createElement("style"); style.id = "custom-home-style"; document.head.appendChild(style); } function getSallaCart() { const interval = setInterval(() => { const sallaCart = document.querySelector(".site-header__cart"); const customContainer = document.querySelector(".header-icons"); if (sallaCart && customContainer) { customContainer.prepend(sallaCart); clearInterval(interval); } }, 200); } function mobileToggleButton() { const menuBtn = document.querySelector(".menu-toggle"); const nav = document.querySelector(".custom-main-nav"); if (!menuBtn || !nav) return; menuBtn.addEventListener("click", () => { nav.classList.toggle("active"); }); } function renderSharedLayout() { const homeBlock = document.querySelector(".home-block"); if (homeBlock) { homeBlock.style.display = "none"; } const footer = document.querySelector("footer"); if (footer) { footer.style.display = "none"; } const hero = document.querySelector(".hero"); if (hero) { hero.style.display = "none"; } const topHeader = document.querySelector(".top-header"); if (topHeader) { topHeader.style.display = "none"; } const siteHeader = document.querySelector("#site-header-outer"); if (siteHeader) { siteHeader.style.position = "absolute"; siteHeader.style.top = "-999px"; } const stickyHeader = document.querySelector(".site-header"); if (stickyHeader) { stickyHeader.style.opacity = 0; } const pageWrapper = document.querySelector(".page-wrapper"); // if (pageWrapper) { // pageWrapper.style.display = "block"; // } // const pageWrapperSuggestions = document.querySelector( // ".page-wrapper.bg-grey", // ); // if (pageWrapperSuggestions) pageWrapperSuggestions.style.display = "block"; const headerWrapper = document.createElement("div"); headerWrapper.id = "custom-header-wrapper"; headerWrapper.innerHTML = sleepTimeHeader; const footerWrapper = document.createElement("div"); footerWrapper.id = "custom-footer-wrapper"; footerWrapper.innerHTML = sleepTimeFooter; pageWrapper.before(headerWrapper); pageWrapper.after(footerWrapper); mobileToggleButton(); getSallaCart(); } async function getMattressProductsLength() { try { const { data } = await salla.api.product.fetch({ source: "search", source_value: "مراتب", }); const count = document.querySelector(".mattresses-count"); count.innerHTML = `+${data.length}منتج`; } catch (error) { console.error(error); } try { const { data } = await salla.api.product.fetch({ source: "search", source_value: "لباد فندقي", }); const count = document.querySelector(".lbad-count"); count.innerHTML = `+${data.length}منتج`; return response.data; } catch (error) { console.error(error); } try { const { data } = await salla.api.product.fetch({ source: "search", source_value: "سرير", }); const count = document.querySelector(".bed-count"); count.innerHTML = `+${data.length}منتج`; } catch (error) { console.error(error); } } async function renderBestSellers() { setTimeout(async () => { try { const response = await salla.api.product.fetch({ source: "category", source_value: "1182297727", }); const products = response.data; const grid = document.querySelector(".product-grid"); if (!grid) return; grid.innerHTML = products .slice(0, 4) .map((product) => createProductCard(product)) .join(""); } catch (error) { console.error(error); } }, 500); } function createProductCard(product) { return `
${product.name}
${product.name}
${product.subtitle ?? ""}
${product.currency} ${product.regular_price} ${ product.regular_price ? `${product.regular_price?.formatted || ""}` : "" }
${product.rating?.average ?? "0"} (${product.rating?.count ?? 0})
`; } function moveTabbyToHero() { const target = document.querySelector("#hero-tabby"); const observer = new MutationObserver(() => { const tabby = document.querySelector(".styles__containerPortal--c9f84"); if (tabby) { target.appendChild(tabby); observer.disconnect(); } }); observer.observe(document.body, { childList: true, subtree: true, }); }