document.addEventListener('DOMContentLoaded', function() {
const productFilter = document.getElementById('product-filter');
if (productFilter) {
productFilter.value = 'bestSell';
}
});
(function() {
'use strict';
function addNewWhatsAppNumber() {
try {
const existingWhatsApp = document.querySelector('a[href*="whatsapp"], a[href*="wa.me"]');
if (!existingWhatsApp) {
return false;
}
const existingNewNumber = document.querySelector('[data-custom-whatsapp="966551054366"]');
if (existingNewNumber) {
return true;
}
let container = existingWhatsApp.closest('#contact-slot') ||
existingWhatsApp.closest('.s-contacts-item') ||
existingWhatsApp.closest('div');
if (!container || !container.parentNode) {
return false;
}
const newWhatsAppElement = document.createElement('div');
newWhatsAppElement.setAttribute('data-custom-whatsapp', '966551054366');
newWhatsAppElement.style.cssText = `
display: block !important;
visibility: visible !important;
margin-top: 10px;
`;
if (container.id && container.id.includes('contact-slot')) {
newWhatsAppElement.id = 'contact-slot-custom-' + Date.now();
}
newWhatsAppElement.innerHTML = `
+966551054366
`;
const link = newWhatsAppElement.querySelector('a');
link.addEventListener('mouseenter', function() {
this.style.backgroundColor = 'rgba(37, 211, 102, 0.1)';
});
link.addEventListener('mouseleave', function() {
this.style.backgroundColor = 'transparent';
});
container.parentNode.insertBefore(newWhatsAppElement, container.nextSibling);
return true;
} catch (error) {
return false;
}
}
function addLinkedInLink() {
const container = document.querySelector('.flex.flex-wrap.gap-3');
if (container) {
const existingLinkedIn = container.querySelector('[data-custom-linkedin="true"]');
if (existingLinkedIn) {
return;
}
const linkedinLink = document.createElement('a');
linkedinLink.href = 'https://www.linkedin.com/in/%D8%B4%D8%B1%D9%83%D8%A9-%D8%A3%D8%B3%D8%A7%D8%B3-%D8%A7%D9%84%D8%AA%D9%85%D9%83%D9%8A%D9%86-%D9%84%D9%84%D8%AA%D8%AF%D8%B1%D9%8A%D8%A8-ba8517286';
linkedinLink.target = '_blank';
linkedinLink.className = 'group flex items-center rounded-full shadow-lg w-12 h-12 overflow-hidden hover:w-48 transition-[width] duration-700 ease-in-out enhanced-social-link';
linkedinLink.style.background = 'linear-gradient(135deg, #0077b5 0%, #005885 100%)';
linkedinLink.setAttribute('data-custom-linkedin', 'true');
linkedinLink.innerHTML = `
in
لينكد إن
`;
container.appendChild(linkedinLink);
}
}
function addTelegramLink() {
const container = document.querySelector('.flex.flex-wrap.gap-3');
if (container) {
const existingTelegram = container.querySelector('[data-custom-telegram="true"]');
if (existingTelegram) {
return;
}
const telegramLink = document.createElement('a');
telegramLink.href = 'https://t.me/asasaltamkeen';
telegramLink.target = '_blank';
telegramLink.className = 'group flex items-center rounded-full shadow-lg w-12 h-12 overflow-hidden hover:w-48 transition-[width] duration-700 ease-in-out enhanced-social-link';
telegramLink.style.background = 'linear-gradient(135deg, #229ED9 0%, #0088cc 100%)';
telegramLink.setAttribute('data-custom-telegram', 'true');
telegramLink.innerHTML = `
تليجرام
`;
container.appendChild(telegramLink);
}
}
// دالة لإضافة كلا الرابطين معاً
function addSocialLinks() {
addLinkedInLink();
addTelegramLink();
}
// تشغيل الدوال عند تحميل الصفحة
document.addEventListener('DOMContentLoaded', function() {
addSocialLinks();
// إضافة مراقب للتغييرات في DOM في حالة تم تحديث المحتوى ديناميكياً
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
addSocialLinks();
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
function addLinkedInLink() {
const container = document.querySelector(".flex.flex-wrap.gap-3");
if (container) {
const existingLinkedIn = container.querySelector(
'[data-custom-linkedin="true"]'
);
if (existingLinkedIn) {
return;
}
const linkedinLink = document.createElement("a");
linkedinLink.href =
"https://www.linkedin.com/in/%D8%B4%D8%B1%D9%83%D8%A9-%D8%A3%D8%B3%D8%A7%D8%B3-%D8%A7%D9%84%D8%AA%D9%85%D9%83%D9%8A%D9%86-%D9%84%D9%84%D8%AA%D8%AF%D8%B1%D9%8A%D8%A8-ba8517286";
linkedinLink.target = "_blank";
linkedinLink.className =
"group flex items-center rounded-full shadow-lg w-12 h-12 overflow-hidden hover:w-48 transition-[width] duration-700 ease-in-out enhanced-social-link";
linkedinLink.style.background =
"linear-gradient(135deg, #0077b5 0%, #005885 100%)";
linkedinLink.setAttribute("data-custom-linkedin", "true");
linkedinLink.innerHTML = `
in
لينكد إن
`;
container.appendChild(linkedinLink);
}
}
function addTelegramLink() {
const container = document.querySelector(".flex.flex-wrap.gap-3");
if (container) {
const existingTelegram = container.querySelector(
'[data-custom-telegram="true"]'
);
if (existingTelegram) {
return;
}
const telegramLink = document.createElement("a");
telegramLink.href = "https://t.me/asasaltamkeen";
telegramLink.target = "_blank";
telegramLink.className =
"group flex items-center rounded-full shadow-lg w-12 h-12 overflow-hidden hover:w-48 transition-[width] duration-700 ease-in-out enhanced-social-link";
telegramLink.style.background =
"linear-gradient(135deg, #229ED9 0%, #0088cc 100%)";
telegramLink.setAttribute("data-custom-telegram", "true");
telegramLink.innerHTML = `
تليجرام
`;
container.appendChild(telegramLink);
}
}
// دالة لإضافة كلا الرابطين معاً
function addSocialLinks() {
addLinkedInLink();
addTelegramLink();
}
// تشغيل الدوال عند تحميل الصفحة
document.addEventListener("DOMContentLoaded", function () {
addSocialLinks();
// إضافة مراقب للتغييرات في DOM في حالة تم تحديث المحتوى ديناميكياً
const observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.addedNodes.length) {
addSocialLinks();
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
});
const videosData = [
{
id: 'bZKhqRkDxs8',
title: 'تأسيس المشاريع بالطريقة الصحيحة ✨'
},
{
id: 'ANJlVxPmI28',
title: 'نبذة عن دورة إدارة المشاريع بالنظام المبسط P3 Express'
},
{
id: 'gBzjN-7VbL8',
title: 'أهمية إدارة المشاريع 💫'
},
{
id: 'vzb0da2nyc4',
title: 'أهمية الادخار والاستثمار في الذهب والفضة ✨'
},
{
id: 'C7Vmh8t47Bg',
title: 'الثراء ليس له طريق واحد فقط 👍🏻'
}
];
function loadSwiper() {
return new Promise((resolve) => {
if (window.Swiper) {
resolve();
return;
}
const swiperCSS = document.createElement('link');
swiperCSS.rel = 'stylesheet';
swiperCSS.href = 'https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css';
document.head.appendChild(swiperCSS);
const swiperJS = document.createElement('script');
swiperJS.src = 'https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js';
swiperJS.onload = resolve;
document.head.appendChild(swiperJS);
});
}
function injectStyles() {
if (document.getElementById('custom-styles')) return;
const style = document.createElement('style');
style.id = 'custom-styles';
style.textContent = `
.custom-videos-section {
background: #0d3257;
padding: 40px 20px;
color: white;
direction: rtl;
font-family: 'Arial', sans-serif;
}
.custom-videos-container {
max-width: 1200px;
margin: 0 auto;
}
.custom-videos-title {
text-align: center;
font-size: 2rem;
font-weight: bold;
margin-bottom: 30px;
}
.custom-video-item {
background: rgba(255, 255, 255, 0.1);
border-radius: 10px;
overflow: hidden;
cursor: pointer;
transition: transform 0.3s;
}
.custom-video-item:hover {
transform: translateY(-5px);
}
.custom-video-thumbnail {
position: relative;
width: 100%;
padding-bottom: 56.25%;
overflow: hidden;
}
.custom-video-thumbnail img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.custom-play-button {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 0, 0, 0.8);
border: none;
border-radius: 50%;
width: 50px;
height: 50px;
color: white;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.custom-video-info {
padding: 15px;
}
.custom-video-title {
font-size: 1rem;
font-weight: 600;
margin: 0;
text-align: right;
}
.video-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.9);
z-index: 9999;
display: none;
align-items: center;
justify-content: center;
}
.video-modal.active {
display: flex;
}
.video-modal-content {
position: relative;
width: 90%;
max-width: 800px;
background: #000;
border-radius: 8px;
overflow: hidden;
}
.video-modal-close {
position: absolute;
top: -40px;
right: 0;
background: rgba(255, 255, 255, 0.2);
border: none;
color: white;
font-size: 24px;
cursor: pointer;
width: 30px;
height: 30px;
border-radius: 50%;
}
.video-iframe {
width: 100%;
height: 450px;
border: none;
}
@media (max-width: 768px) {
.video-iframe {
height: 250px;
}
.custom-videos-title {
font-size: 1.5rem;
}
}
`;
document.head.appendChild(style);
}
function openVideoModal(videoId) {
let modal = document.getElementById('video-modal');
if (!modal) {
modal = document.createElement('div');
modal.id = 'video-modal';
modal.className = 'video-modal';
modal.innerHTML = `
`;
document.body.appendChild(modal);
modal.addEventListener('click', function(e) {
if (e.target === modal) {
closeVideoModal();
}
});
}
const iframe = modal.querySelector('.video-iframe');
iframe.src = `https://www.youtube.com/embed/${videoId}?autoplay=1`;
modal.classList.add('active');
}
window.closeVideoModal = function() {
const modal = document.getElementById('video-modal');
if (modal) {
modal.classList.remove('active');
setTimeout(() => {
const iframe = modal.querySelector('.video-iframe');
iframe.src = '';
}, 300);
}
}
function createVideoSection() {
if (!document.body.classList.contains('index')) return null;
const existingSection = document.querySelector('.custom-videos-section');
if (existingSection) {
return existingSection;
}
const section = document.createElement('section');
section.className = 'custom-videos-section';
section.innerHTML = `
قناة أساس التمكين للتدريب
${videosData.map(video => `
${video.title}
`).join('')}
`;
const targetSection = document.getElementById('IRT__fixed-5');
if (targetSection) {
targetSection.parentNode.insertBefore(section, targetSection.nextSibling);
} else {
const mainContent = document.querySelector('main, .main-content, body');
if (mainContent) mainContent.appendChild(section);
}
return section;
}
async function initVideoSection() {
if (!document.body.classList.contains('index')) return;
if (document.querySelector('.custom-videos-section')) {
return;
}
try {
await loadSwiper();
injectStyles();
const section = createVideoSection();
if (section) {
setTimeout(() => {
if (!section.querySelector('.swiper-initialized')) {
new Swiper('.custom-videos-swiper', {
loop: true,
autoplay: {
delay: 4000,
disableOnInteraction: false,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
slidesPerView: 1,
spaceBetween: 20,
breakpoints: {
768: { slidesPerView: 2 },
1024: { slidesPerView: 3 }
}
});
document.querySelectorAll('.custom-video-item').forEach(item => {
item.addEventListener('click', function() {
const videoId = this.getAttribute('data-video-id');
if (videoId) openVideoModal(videoId);
});
});
}
}, 500);
}
} catch (error) {}
}
let isRunning = false;
let elementsAdded = {
whatsapp: false,
linkedin: false,
videos: false
};
function checkElementsStatus() {
elementsAdded.whatsapp = !!document.querySelector('[data-custom-whatsapp="966551054366"]');
elementsAdded.linkedin = !!document.querySelector('[data-custom-linkedin="true"]');
elementsAdded.videos = !!document.querySelector('.custom-videos-section');
return elementsAdded;
}
let observer;
let observerTimeout;
function startObserver() {
if (observer) observer.disconnect();
observer = new MutationObserver(function(mutations) {
if (observerTimeout) {
clearTimeout(observerTimeout);
}
observerTimeout = setTimeout(() => {
let shouldRun = false;
mutations.forEach(function(mutation) {
const isCustomChange = Array.from(mutation.addedNodes).some(node =>
node.nodeType === 1 && (
(node.hasAttribute && (
node.hasAttribute('data-custom-whatsapp') ||
node.hasAttribute('data-custom-linkedin') ||
node.classList?.contains('custom-videos-section')
)) ||
(node.querySelector && (
node.querySelector('[data-custom-whatsapp]') ||
node.querySelector('[data-custom-linkedin]') ||
node.querySelector('.custom-videos-section')
))
)
);
if (isCustomChange) return;
if (mutation.type === 'childList' &&
(mutation.addedNodes.length > 0 || mutation.removedNodes.length > 0)) {
shouldRun = true;
}
});
if (shouldRun && !isRunning) {
checkElementsStatus();
const missingElements = !elementsAdded.whatsapp || !elementsAdded.linkedin;
if (missingElements) {
initAll();
}
}
}, 2000);
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}
function initAll() {
if (isRunning) {
return;
}
isRunning = true;
try {
checkElementsStatus();
if (!elementsAdded.whatsapp) {
const whatsappSuccess = addNewWhatsAppNumber();
if (whatsappSuccess) {
elementsAdded.whatsapp = true;
}
}
if (!elementsAdded.linkedin) {
addLinkedInLink();
elementsAdded.linkedin = !!document.querySelector('[data-custom-linkedin="true"]');
}
if (document.body.classList.contains('index') && !elementsAdded.videos) {
initVideoSection();
setTimeout(() => {
elementsAdded.videos = !!document.querySelector('.custom-videos-section');
}, 1000);
}
} catch (error) {
} finally {
setTimeout(() => {
isRunning = false;
}, 500);
}
}
function startSystem() {
checkElementsStatus();
initAll();
startObserver();
setInterval(function() {
if (isRunning) return;
const currentStatus = checkElementsStatus();
const missingElements = !currentStatus.whatsapp || !currentStatus.linkedin;
if (missingElements) {
initAll();
}
}, 500);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', startSystem);
} else {
startSystem();
}
})();
function moveBlogs() {
const blogs = document.querySelectorAll('#blog');
const mainMenu = document.querySelector('.main-menu');
if (blogs.length > 0 && mainMenu) {
blogs.forEach(item => {
mainMenu.appendChild(item);
});
} else {
// جرب تاني بعد شوية
setTimeout(moveBlogs, 500);
}
}
// بداية التنفيذ
moveBlogs();
// دالة لاستبدال كلمة "منتجات" و "منتج" بـ "دورات"
function replaceProductsWithCourses() {
// البحث عن العنصر المحدد
const titleElement = document.getElementById('page-main-title');
if (titleElement) {
// الحصول على النص الحالي
let currentText = titleElement.innerHTML;
// استبدال "منتجات" بـ "دورات"
currentText = currentText.replace(/منتجات/g, 'دورات');
// استبدال "منتج" بـ "دورة" (للمفرد)
currentText = currentText.replace(/منتج/g, 'دورة');
// تحديث النص
titleElement.innerHTML = currentText;
console.log('تم استبدال النص بنجاح');
} else {
console.log('لم يتم العثور على العنصر');
}
}
// دالة أكثر شمولية للبحث في جميع العناصر التي تحتوي على كلاس معين
function replaceAllProductsText() {
// البحث في العنصر الرئيسي أولاً
replaceProductsWithCourses();
// البحث في جميع العناصر التي تحتوي على "منتج" أو "منتجات"
const allElements = document.querySelectorAll('*');
allElements.forEach(element => {
// فحص النص المباشر للعنصر (بدون العناصر الفرعية)
if (element.childNodes.length > 0) {
element.childNodes.forEach(node => {
if (node.nodeType === Node.TEXT_NODE) {
let text = node.textContent;
if (text.includes('منتجات') || text.includes('منتج')) {
text = text.replace(/منتجات/g, 'دورات');
text = text.replace(/منتج/g, 'دورة');
node.textContent = text;
}
}
});
}
});
}
// تشغيل الكود عند تحميل الصفحة
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', replaceAllProductsText);
} else {
replaceAllProductsText();
}
// مراقبة التغييرات في الصفحة (لحالة المواقع الديناميكية)
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length > 0) {
// تأخير صغير للتأكد من تحميل المحتوى
setTimeout(replaceAllProductsText, 100);
}
});
});
// بدء مراقبة التغييرات
observer.observe(document.body, {
childList: true,
subtree: true
});
// دالة يمكن استدعاؤها يدوياً
window.replaceProductsText = replaceAllProductsText;