document.addEventListener("DOMContentLoaded", function() {
/* Add custom Js code below */
const meta = document.createElement('meta');
meta.name = 'p:domain_verify';
meta.content = 'adeb506dfbee0acc7888e1dc5066330d';
document.getElementsByTagName('head')[0].appendChild(meta);
let logo = document.querySelector(".navbar-brand img"); // Select the logo image
let lang = document.documentElement.lang; // Get the current language from the HTML tag
if (lang === "ar") {
logo.src = "https://cdn.salla.sa/form-builder/RbM9k5Xk3pXRLDPnlK2eJjTipEcODFaiQrMHqCzc.png"; // Arabic logo
} else {
logo.src = "https://cdn.salla.sa/form-builder/FEjEAElMoBH45ijx7dxwYP7DN0McCRWk0VRVef2t.png"; // English logo
}
});
document.addEventListener("DOMContentLoaded", function () {
// Select the footer menu list
const footerMenuList = document.querySelector(".footer-menu-list");
const htmlLang = document.documentElement.lang; // Get the current language
if (footerMenuList) {
// Define text for both languages
const isArabic = htmlLang === "ar";
const storeTitle = isArabic ? "المتجر" : "Store";
const aboutUs = isArabic ? "من نحن" : "About Us";
const contactUs = isArabic ? "اتصل بنا" : "Contact Us";
const customerServiceTitle = isArabic ? "خدمة العملاء" : "Customer Service";
const findUs = isArabic ? "اعثر علينا" : "Find Us";
const makeAnEnquiry = isArabic ? "قدم استفسار للمشاريع" : "Project Enquiry"; // Added translation
const legalPrivacy = isArabic ? "الخصوصية القانونية" : "Legal & Privacy";
const shippingPolicy = isArabic ? "سياسة الشحن والإرجاع" : "Shipping & Returns Policy";
// Create the new sections
const storeSection = document.createElement("div");
storeSection.className = "footer-column store-column1";
storeSection.innerHTML = `
`;
const customerServiceSection = document.createElement("div");
customerServiceSection.className = "footer-column customer-service-column2";
customerServiceSection.innerHTML = `
`;
// Find the Contact Us section
const contactUsSection = document.querySelector(".contacts-widget");
if (contactUsSection) {
// Insert the new sections beside the Contact Us section
contactUsSection.parentNode.insertBefore(storeSection, contactUsSection.nextSibling);
contactUsSection.parentNode.insertBefore(customerServiceSection, storeSection.nextSibling);
}
}
});
document.addEventListener("DOMContentLoaded", function () {
// Find the with "اعثر علينا" (Arabic) or "Find Us" (English)
const findUsHeading = document.querySelector("h1.font-bold");
if (findUsHeading) {
const headingText = findUsHeading.textContent.trim();
// Clear any existing content before inserting new elements
if (headingText === "Find Us" || headingText === "اعثر علينا") {
let titleText, descriptionText, imageLinks;
if (headingText === "Find Us") {
// English version content
titleText = "OUR FLAGSHIP SHOWROOMS";
descriptionText = "Find Your Loft Furniture Showroom";
imageLinks = [
{
src: "https://cdn.salla.sa/mQYPPa/0QIer2O1BOGGkhM3meXEwXVGwCKcLU3xLpzu3JzO.png",
link: "https://maps.app.goo.gl/zxsJe6AsJ33544tk6",
},
{
src: "https://cdn.salla.sa/mQYPPa/yzWhkNtTCa5wrvIynllyXRsd45MXd8FrQdlYd2kr.png",
link: "https://maps.app.goo.gl/n1fhrPcJz6ipr6zr7",
},
{
src: "https://cdn.salla.sa/mQYPPa/Z7qB6REJyGzuGQ4u32drKpifjojHdGIdkt1h0lfP.png",
link: "https://maps.app.goo.gl/UbBbLcgpfS3Wt2A99",
},
{
src: "https://cdn.salla.sa/mQYPPa/it613h3KQSB2Zxh5MQnWxue2jmkKfRQLkQSGF2Z1.png",
link: "https://maps.app.goo.gl/gQRd8ifknqb5NUNc7",
},
{
src: "https://cdn.salla.sa/mQYPPa/MC9Q0TPnVDjy3K3ORIhGyHuIxzpSEwOCjITTXyEj.png",
link: "https://maps.app.goo.gl/gyhcSD5eGRKDxm1d9",
},
{
src: "https://cdn.salla.sa/mQYPPa/vhTOpSVKQeQFgw72XKOKcRe5R7EXNmvMJbophmr2.png",
link: "https://maps.app.goo.gl/NHZZAuXSEb1F6W8H6",
},
];
} else {
// Arabic version content
titleText = "معارضنا الرئيسية";
descriptionText = "اعثر على صالة عرض مفروشات لوفت الخاصة بك";
imageLinks = [
{
src: "https://cdn.salla.sa/mQYPPa/JS4TNicJYQ35yweAfTxTWCOvmGMLcc0sBKOgdFem.png",
link: "https://maps.app.goo.gl/zxsJe6AsJ33544tk6",
},
{
src: "https://cdn.salla.sa/mQYPPa/dWvtVFlGC1kRmE2VfyjyhXaJyVXivufBRkQVQjJx.png",
link: "https://maps.app.goo.gl/n1fhrPcJz6ipr6zr7",
},
{
src: "https://cdn.salla.sa/mQYPPa/hbwyKsQieKYnUWfYkym4OEzPjNvIkR1XxvSaW9cz.png",
link: "https://maps.app.goo.gl/UbBbLcgpfS3Wt2A99",
},
{
src: "https://cdn.salla.sa/mQYPPa/pvfSjk1LXSYYlIjbb6f0PiqsVZ2KYDGyBrLS2kn3.png",
link: "https://maps.app.goo.gl/gQRd8ifknqb5NUNc7",
},
{
src: "https://cdn.salla.sa/mQYPPa/UTWWUEU9VfcTcMDp6EXdYJYatATwQOm6X6i8UV85.png",
link: "https://maps.app.goo.gl/gyhcSD5eGRKDxm1d9",
},
{
src: "https://cdn.salla.sa/mQYPPa/vhTOpSVKQeQFgw72XKOKcRe5R7EXNmvMJbophmr2.png",
link: "https://maps.app.goo.gl/NHZZAuXSEb1F6W8H6",
},
];
}
// Create the top section with title, description, and first two images
const topContainer = document.createElement("div");
topContainer.style.display = "flex";
topContainer.style.justifyContent = "space-between";
topContainer.style.alignItems = "center";
topContainer.style.flexWrap = "wrap";
topContainer.style.width = "100%";
// Create the text container for title and description
const textContainer = document.createElement("div");
textContainer.style.width = "33%";
textContainer.style.textAlign = "center";
const title = document.createElement("h2");
title.textContent = titleText;
title.style.fontSize = "24px";
title.style.fontWeight = "bold";
const description = document.createElement("p");
description.textContent = descriptionText;
description.style.fontSize = "16px";
description.style.color = "#666";
description.style.margin = "0";
textContainer.appendChild(title);
textContainer.appendChild(description);
// Create two images with links
function createImageLink(image) {
const imgLink = document.createElement("a");
imgLink.href = image.link;
imgLink.target = "_blank";
imgLink.style.width = "33%";
const img = document.createElement("img");
img.src = image.src;
img.style.width = "100%";
img.style.borderRadius = "5px";
img.style.margin = "5px";
imgLink.appendChild(img);
return imgLink;
}
const img1 = createImageLink(imageLinks[0]);
const img2 = createImageLink(imageLinks[1]);
// Append elements to the top container
topContainer.appendChild(textContainer);
topContainer.appendChild(img1);
topContainer.appendChild(img2);
// Create a container for the three remaining images
const bottomContainer = document.createElement("div");
bottomContainer.style.display = "flex";
bottomContainer.style.justifyContent = "space-between";
bottomContainer.style.flexWrap = "wrap";
bottomContainer.style.width = "100%";
bottomContainer.style.marginBottom = "10px";
for (let i = 2; i < imageLinks.length; i++) {
bottomContainer.appendChild(createImageLink(imageLinks[i]));
}
// Create Google Maps iframe
const iframe = document.createElement("iframe");
iframe.src = "https://www.google.com/maps/d/embed?mid=1r45nEWweR7mJlbrDlMOZb5L8pZKrskQ&hl=en&ehbc=2E312F";
iframe.width = "100%";
iframe.height = "700";
iframe.style.border = "0";
iframe.style.marginTop = "10px";
// Insert elements into the DOM
findUsHeading.insertAdjacentElement("afterend", iframe);
findUsHeading.insertAdjacentElement("afterend", bottomContainer);
findUsHeading.insertAdjacentElement("afterend", topContainer);
// Apply responsive styles dynamically
function applyResponsiveStyles() {
if (window.innerWidth < 500) {
topContainer.style.flexDirection = "column";
topContainer.style.alignItems = "center";
textContainer.style.width = "100%";
img1.style.width = "100%";
img2.style.width = "100%";
bottomContainer.style.flexDirection = "column";
bottomContainer.childNodes.forEach(child => {
child.style.width = "100%";
});
} else {
topContainer.style.flexDirection = "row";
textContainer.style.width = "33%";
img1.style.width = "33%";
img2.style.width = "33%";
bottomContainer.style.flexDirection = "row";
bottomContainer.childNodes.forEach(child => {
child.style.width = "33%";
});
}
}
// Apply styles on page load and resize
applyResponsiveStyles();
window.addEventListener("resize", applyResponsiveStyles);
}
}
});
document.addEventListener("DOMContentLoaded", function () {
const findUsHeading = document.querySelector("h1.font-bold");
if (findUsHeading) {
const headingText = findUsHeading.textContent.trim();
if (headingText === "Project Enquiry" || headingText === "قم بإجراء استفسار") {
// Create banner image element
const banner = document.createElement("img");
banner.src = "https://cdn.salla.sa/mQYPPa/xfdMjNpM8YhqLHkUERnlVsHAwTXPaT59lMWw5ZD3.jpg";
banner.classList.add("banner-form"); // Add class for banner image
// Create a flex container
const container = document.createElement("div");
container.classList.add("flex-form"); // Add class for flex container
// Create an image element
const image = document.createElement("img");
image.src = "https://cdn.salla.sa/mQYPPa/GOwj7Emwp3rCQC9eUDsxwpzQq8EvYgri6wadWspw.jpg";
image.classList.add("flex-form-image"); // Add class for image column
// Create a div for the iframe
const iframeContainer = document.createElement("div");
iframeContainer.classList.add("flex-form-iframe"); // Add class for iframe column
iframeContainer.innerHTML = `
`;
// Append the image and iframe container to the flex container
container.appendChild(image);
container.appendChild(iframeContainer);
// Insert the banner and flex container after the heading
findUsHeading.insertAdjacentElement("afterend", banner);
banner.insertAdjacentElement("afterend", container);
}
}
});
function formatPrices() {
const elements = document.querySelectorAll(".total-price, .before-price, .sale-price");
elements.forEach(el => {
const textNode = Array.from(el.childNodes).find(n => n.nodeType === Node.TEXT_NODE);
if (textNode) {
const value = textNode.nodeValue.trim().replace(/,/g, "");
const number = parseFloat(value);
if (!isNaN(number)) {
const formatted = number.toLocaleString("en-US", { minimumFractionDigits: 2 });
textNode.nodeValue = formatted + " ";
}
}
});
}
// Run once at the start
formatPrices();
// Set up a MutationObserver to re-format if products are loaded dynamically
const observer = new MutationObserver(formatPrices);
observer.observe(document.body, {
childList: true,
subtree: true,
});