/* ========================================================================== 💬 نظام الدردشة الذكي + منصات التواصل ========================================================================== */ class SmartChatWidget { constructor() { // ✏️ عدّل بيانات التواصل من هنا this.phoneNumber = '0590016037'; this.whatsappNumber = '966590016037'; // بدون + this.whatsappMessage = 'مرحباً، أحتاج مساعدة'; this.socialLinks = { instagram: 'https://www.instagram.com/peurma.sa', twitter: 'https://x.com/Peurma_SA', snapchat: 'https://www.snapchat.com/add/peurma_sa', tiktok: 'https://www.tiktok.com/@peurma.sa', facebook: 'https://www.facebook.com/profile.php?id=61573274226382' }; this.init(); } init() { this.createWidget(); this.setupEvents(); this.startNotifications(); } createWidget() { // حذف أي widget قديم document.querySelector('.chat-widget')?.remove(); document.querySelector('.chat-overlay')?.remove(); // إنشاء Overlay this.overlay = document.createElement('div'); this.overlay.className = 'chat-overlay'; document.body.appendChild(this.overlay); // إنشاء Widget this.widget = document.createElement('div'); this.widget.className = 'chat-widget'; this.widget.innerHTML = this.getWidgetHTML(); document.body.appendChild(this.widget); // مراجع سريعة this.toggle = this.widget.querySelector('.chat-toggle'); this.menu = this.widget.querySelector('.chat-menu'); this.badge = this.widget.querySelector('.chat-badge'); this.tooltip = this.widget.querySelector('.chat-tooltip'); } getWidgetHTML() { const waLink = `https://wa.me/${this.whatsappNumber}?text=${encodeURIComponent(this.whatsappMessage)}`; return ` تبي مساعدة؟
`; } setupEvents() { this.toggle.addEventListener('click', (e) => { e.stopPropagation(); this.toggleMenu(); }); this.overlay.addEventListener('click', () => this.closeMenu()); document.addEventListener('click', (e) => { if (!this.widget.contains(e.target) && this.widget.classList.contains('open')) { this.closeMenu(); } }); document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && this.widget.classList.contains('open')) { this.closeMenu(); } }); this.toggle.addEventListener('mouseenter', () => { if (!this.widget.classList.contains('open')) { this.tooltip.classList.add('show'); } }); this.toggle.addEventListener('mouseleave', () => { setTimeout(() => { if (!this.badge.classList.contains('show')) { this.tooltip.classList.remove('show'); } }, 500); }); } toggleMenu() { this.widget.classList.contains('open') ? this.closeMenu() : this.openMenu(); } openMenu() { this.widget.classList.add('open'); this.overlay.classList.add('show'); this.badge.classList.remove('show'); this.tooltip.classList.remove('show'); } closeMenu() { this.widget.classList.remove('open'); this.overlay.classList.remove('show'); } startNotifications() { const showNotification = () => { if (this.widget.classList.contains('open')) return; this.badge.classList.add('show'); setTimeout(() => this.tooltip.classList.add('show'), 300); setTimeout(() => this.tooltip.classList.remove('show'), 5300); setTimeout(() => this.badge.classList.remove('show'), 6000); if (window.navigator.vibrate) { window.navigator.vibrate([100, 50, 100]); } }; setTimeout(showNotification, 5000); // أول إشعار بعد 5 ثواني setInterval(showNotification, 30000); // ثم كل 30 ثانية } } // تشغيل document.addEventListener('DOMContentLoaded', () => { new SmartChatWidget(); }); document.addEventListener("DOMContentLoaded", function () { var banners = document.querySelectorAll(".js-promo-banner"); banners.forEach(function (banner) { function pressOn() { banner.classList.add("is-pressed"); } function pressOff() { banner.classList.remove("is-pressed"); } banner.addEventListener("pointerdown", pressOn, { passive: true }); banner.addEventListener("pointerup", pressOff, { passive: true }); banner.addEventListener("pointerleave", pressOff, { passive: true }); banner.addEventListener("pointercancel", pressOff, { passive: true }); banner.addEventListener("touchstart", pressOn, { passive: true }); banner.addEventListener("touchend", pressOff, { passive: true }); banner.addEventListener("touchcancel", pressOff, { passive: true }); banner.addEventListener("dragstart", function (e) { e.preventDefault(); }); }); }); (function() { var schema = document.createElement('script'); schema.type = 'application/ld+json'; schema.text = JSON.stringify({ "@context": "https://schema.org", "@graph": [ { "@type": "Organization", "@id": "https://peurma.com/#organization", "name": "بيورما Peurma", "url": "https://peurma.com", "description": "متجر بيورما لفلاتر المياه والبرادات ذاتية التعبئة في السعودية. توصيل وتركيب مجاني في الرياض وجدة والدمام.", "areaServed": ["الرياض","جدة","الدمام"], "address": { "@type": "PostalAddress", "addressCountry": "SA" } }, { "@type": "WebSite", "@id": "https://peurma.com/#website", "url": "https://peurma.com", "name": "بيورما Peurma", "inLanguage": "ar", "publisher": {"@id": "https://peurma.com/#organization"}, "potentialAction": { "@type": "SearchAction", "target": { "@type": "EntryPoint", "urlTemplate": "https://peurma.com/search?q={search_term_string}" }, "query-input": "required name=search_term_string" } } ] }); document.head.appendChild(schema); })(); // إضافة offers لـ Product Schema تلقائياً document.addEventListener('DOMContentLoaded', function() { document.querySelectorAll('script[type="application/ld+json"]').forEach(function(tag) { try { var data = JSON.parse(tag.textContent); var products = []; if (data['@type'] === 'Product') products = [data]; else if (Array.isArray(data)) products = data.filter(function(i){ return i['@type']==='Product'; }); else if (data['@graph']) products = data['@graph'].filter(function(i){ return i['@type']==='Product'; }); if (!products.length) return; products.forEach(function(p) { if (p.offers) return; var priceEl = document.querySelector('.product__price .price, [data-product-price], .product-price'); var price = priceEl ? priceEl.textContent.replace(/[^\d.]/g,'').trim() : null; p.offers = { "@type": "Offer", "priceCurrency": "SAR", "availability": "https://schema.org/InStock", "seller": {"@type":"Organization","name":"بيورما Peurma"}, "areaServed": {"@type":"Country","name":"SA"}, "shippingDetails": { "@type": "OfferShippingDetails", "shippingRate": {"@type":"MonetaryAmount","value":"0","currency":"SAR"}, "shippingDestination": {"@type":"DefinedRegion","addressCountry":"SA"} } }; if (price) p.offers.price = price; }); tag.textContent = JSON.stringify(data); } catch(e) {} }); }); // إضافة llms.txt link للـ head لمساعدة AI crawlers var link = document.createElement('link'); link.rel = 'llms'; link.href = 'https://peurma.com/blog/llms.txt'; document.head.appendChild(link);