document.addEventListener('DOMContentLoaded', () => {
// 1. منطق واتساب (WhatsApp Animation)
const waLink = document.querySelector('#wa-angel a');
if (waLink && !waLink.querySelector('.wa-flip-wrapper')) {
const imgSrc = "/api/public/proxy/__h/cdn.salla.sa/cdn-cgi/image/fit=scale-down,width=400,height=400,onerror=redirect,format=auto/ydvXPz/NMyd5Nn7JtNUKjV9sWauoPtDwaYwjNTC12XNiTwB.png";
const originalIcon = waLink.innerHTML;
waLink.innerHTML = '';
const flipWrapper = document.createElement('div');
flipWrapper.className = 'wa-flip-wrapper';
flipWrapper.innerHTML = `
`;
waLink.appendChild(flipWrapper);
setInterval(() => {
flipWrapper.classList.toggle('is-flipped');
}, 4500);
}
// 2. تفعيل التلاشي للعناصر (IntersectionObserver)
const elements = document.querySelectorAll(".sbauth, .s-product-card, section");
if (elements.length) {
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("reveal-visible");
observer.unobserve(entry.target);
}
});
}, { threshold: 0.1 });
elements.forEach(el => observer.observe(el));
}
// 3. إضافة أيقونة LinkedIn
function addLinkedinIcon() {
const socialLists = document.querySelectorAll('.s-social-list');
socialLists.forEach(socialList => {
if (socialList.querySelector('.linkedin-custom')) return;
const linkedinLi = document.createElement('li');
linkedinLi.className = 's-social-link linkedin-custom';
linkedinLi.style.display = 'inline-block';
linkedinLi.innerHTML = ``;
socialList.appendChild(linkedinLi);
});
}
addLinkedinIcon();
new MutationObserver(addLinkedinIcon).observe(document.body, { childList: true, subtree: true });
// 4. إنشاء زر نقاط الولاء
const loyaltyButton = document.createElement('button');
loyaltyButton.type = 'button';
loyaltyButton.className = 'ratingplus-loyalty-launcher';
loyaltyButton.style.cssText = `position: fixed; z-index: 99998; display: flex; align-items: center; justify-content: center; padding: 18px 16px; background-color: rgb(107, 79, 71); color: rgb(255, 255, 255); border: none; font-size: 16px; font-weight: 600; cursor: pointer; top: 50%; left: 0px; transform: translateY(-50%); width: 55px; min-height: 120px; box-shadow: rgba(0, 0, 0, 0.1) 2px 0px 8px; border-radius: 0px 8px 8px 0px;`;
loyaltyButton.innerHTML = ``;
loyaltyButton.addEventListener('click', () => window.location.href = '/api/public/proxy/loyalty');
document.body.appendChild(loyaltyButton);
});