/* Add custom Js code below */ // Detect language const lang = document.documentElement.lang || 'ar'; const createAccordion = (data, parent, head = true, order = "before") => { if (!data || !Array.isArray(data) || data.length === 0) return; const section = document.createElement('section'); section.className = 'accordion-section'; if (head) { const heading = document.createElement('div'); heading.innerHTML = lang === 'en' ? `

Frequently Asked Questions

Get to know us more .

` : `

اهم الاسئلة

تعرف علينا أكثر

`; section.append(heading); } const accorCon = document.createElement('div'); accorCon.className = 'accordion'; data.forEach(({ title, content }) => { const button = document.createElement('button'); button.className = 'accordion-button'; button.innerHTML = `${title} +`; const contentDiv = document.createElement('div'); contentDiv.className = 'accordion-content'; typeof content === 'string' && content.includes('<')? contentDiv.innerHTML = content : contentDiv.innerHTML = `

${content}

`; button.addEventListener('click', () => { const isActive = button.classList.toggle('active'); button.querySelector('.icon').textContent = isActive ? '−' : '+'; contentDiv.style.maxHeight = isActive ? `${contentDiv.scrollHeight}px` : null; }); accorCon.append(button, contentDiv); }); section.append(accorCon); order === 'before' ? parent.before(section) : parent.after(section); }; document.addEventListener("DOMContentLoaded", () => { const proForm = document.querySelector('.product-single .main-content>.flex.whitespace-nowrap.gap-4.items-center:nth-of-type(1)'); if (proForm) { const proDes = document.querySelector('.product-single .product__description article'); const validData = lang === 'en' ? [ { title: "Product Description", content: proDes ? proDes.innerHTML : "" }, { title: "Shipping and Delivery", content: "

For shipping and delivery details, click here.

" } ] : [ { title: "وصف المنتج", content: proDes ? proDes.innerHTML : "" }, { title: "التوصيل والشحن", content: "

لمعرفة تفاصيل الشحن والتوصيل اضغط هنا

" } ]; createAccordion(validData, proForm, false, "after"); proDes.remove(); } });