/* Add custom Js styles below */ // ========== إعدادات ========== const WHATSAPP_URL = "https://wa.me/966547226514"; const SITE_URL = "https://shokvat.com"; // تجنب التكرار لو الكود اتشغّل أكتر من مرة if (!window.__shokvatInjected__) { window.__shokvatInjected__ = true; document.addEventListener("DOMContentLoaded", function () { // 1) إنشاء نص الفوتر بالرابط let footerText = document.querySelector(".custom-footer-text"); if (!footerText) { footerText = document.createElement("div"); footerText.className = "custom-footer-text"; footerText.innerHTML = 'تصميم وإدارة شوكفات'; document.body.appendChild(footerText); } else { // لو موجود بالفعل، نخلي الرابط يشتغل كبوابة للمودال const link = footerText.querySelector("a") || (() => { const a = document.createElement("a"); a.id = "shokvatLink"; a.textContent = "شوكفات"; a.href = "#"; footerText.append(" ", a); return a; })(); link.id = "shokvatLink"; link.href = "#"; link.setAttribute("role", "button"); link.removeAttribute("target"); } // 2) إنشاء المودال بالكامل بالـJS (بدون HTML جاهز) if (!document.getElementById("shokvatModal")) { const modal = document.createElement("div"); modal.id = "shokvatModal"; modal.innerHTML = ` `; document.body.appendChild(modal); // إغلاق بالزر modal.querySelector(".shokvat-close-btn").addEventListener("click", function () { modal.style.display = "none"; document.body.classList.remove("shokvat-no-scroll"); }); // إغلاق بالضغط خارج المحتوى modal.addEventListener("click", function (e) { if (e.target.id === "shokvatModal") { modal.style.display = "none"; document.body.classList.remove("shokvat-no-scroll"); } }); // إغلاق بمفتاح ESC document.addEventListener("keydown", function (e) { if (e.key === "Escape" && modal.style.display === "flex") { modal.style.display = "none"; document.body.classList.remove("shokvat-no-scroll"); } }); } // 3) ربط الضغط على "شوكفات" بفتح المودال const trigger = document.getElementById("shokvatLink"); const modalEl = document.getElementById("shokvatModal"); if (trigger && modalEl) { trigger.addEventListener("click", function (e) { e.preventDefault(); modalEl.style.display = "flex"; document.body.classList.add("shokvat-no-scroll"); }); } }); } document.addEventListener("DOMContentLoaded", function () { // لا يظهر في الصفحة الرئيسية فقط if (window.location.pathname !== "/") { const helpBtn = document.createElement('div'); helpBtn.id = 'floating-help-btn'; helpBtn.innerHTML = ``; helpBtn.style.cssText = ` position: fixed; bottom: 90px; left: 20px; /* ← هنا التغيير */ width: 50px; height: 50px; background-color: #f97316; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 99999; box-shadow: 0 4px 12px rgba(0,0,0,0.25); transition: transform 0.3s ease; `; helpBtn.onmouseover = () => { helpBtn.style.transform = 'scale(1.1)'; }; helpBtn.onmouseout = () => { helpBtn.style.transform = 'scale(1)'; }; // عند الضغط عليه يفتح نافذة التسجيل helpBtn.onclick = () => { if (typeof salla !== 'undefined' && salla.event) { salla.event.dispatch('login::open'); } else { alert("حدث خطأ، تأكد من تحميل مكتبة سلة."); } }; document.body.appendChild(helpBtn); } }); // إنشاء زر الواتساب ديناميكيًا (منع التكرار) if (!document.getElementById('whatsapp-btn')) { const whatsappButton = document.createElement('div'); whatsappButton.id = 'whatsapp-btn'; whatsappButton.innerHTML = ` WhatsApp `; // فتح واتساب عند النقر whatsappButton.onclick = function () { window.open('https://wa.me/+966566553890', '_blank'); }; // إضافة الزر إلى الصفحة document.body.appendChild(whatsappButton); } document.addEventListener("DOMContentLoaded", function () { const anchor = document.querySelector('.product__description'); if (!anchor) return; if (document.getElementById('tm-window')) return; const COUPON_CODE = 'ND95'; const box = document.createElement('div'); box.id = 'tm-window'; const closeBtn = document.createElement('button'); closeBtn.className = 'tm-close'; closeBtn.setAttribute('aria-label', 'إغلاق النافذة'); closeBtn.textContent = '×'; const head = document.createElement('div'); head.className = 'tm-head'; head.innerHTML = ` 🛒 Tech Market عرض خاص `; const msg = document.createElement('div'); msg.className = 'tm-msg'; msg.innerHTML = ` ⚡️ خصم جبّار بمناسبة اليوم الوطني 95
استخدم الكوبون التالي واستمتع بتجربة تسوّق مميزة. `; const codeWrap = document.createElement('div'); codeWrap.className = 'tm-code'; const input = document.createElement('input'); input.className = 'tm-input'; input.type = 'text'; input.value = COUPON_CODE; input.readOnly = true; const copyBtn = document.createElement('button'); copyBtn.className = 'tm-copy'; copyBtn.textContent = '📋 نسخ الكود'; copyBtn.addEventListener('click', async () => { try { await navigator.clipboard.writeText(COUPON_CODE); const old = copyBtn.textContent; copyBtn.textContent = '✅ تم النسخ!'; setTimeout(() => (copyBtn.textContent = old), 1800); } catch (e) { alert('انسخ الكود يدويًا: ' + COUPON_CODE); } }); closeBtn.addEventListener('click', () => { sessionStorage.setItem('tm_dismissed', '1'); box.remove(); }); if (sessionStorage.getItem('tm_dismissed') === '1') return; const deco = document.createElement('div'); deco.className = 'tm-circuit'; codeWrap.appendChild(input); codeWrap.appendChild(copyBtn); box.appendChild(closeBtn); box.appendChild(head); box.appendChild(msg); box.appendChild(codeWrap); box.appendChild(deco); anchor.parentNode.insertBefore(box, anchor); requestAnimationFrame(() => { box.classList.add('tm--in'); }); }); setTimeout(() => { // التحقق إذا تم عرض التنبيه مسبقًا if (!localStorage.getItem('discountAlertShown')) { // إنشاء عنصر التنبيه let discountAlert = document.createElement('div'); discountAlert.id = 'discount-alert'; discountAlert.innerHTML = `
🇸🇦 خصم خاص بمناسبة اليوم الوطني السعودي 95 🎉

استخدم الكود ND95
للحصول على خصم فوري عند الشراء

`; // إضافة التنبيه إلى الصفحة document.body.appendChild(discountAlert); // وظيفة زر "إغلاق" document.getElementById('close-alert').onclick = () => { discountAlert.style.display = 'none'; }; // وظيفة زر "انسخ الكود" document.getElementById('copy-code').onclick = () => { navigator.clipboard.writeText('ND95').then(() => { alert('✅ تم نسخ الكود: ND95 - استخدمه عند إتمام عملية الشراء!'); discountAlert.style.display = 'none'; // إغلاق النافذة بعد النسخ }).catch(err => { console.error('فشل النسخ: ', err); }); }; // تخزين حالة التنبيه في Local Storage localStorage.setItem('discountAlertShown', 'true'); } }, 5000); // يظهر بعد 5 ثوانٍ