<!-- 🔥 1. رابط Font Awesome للأيقونات -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- 🔥 2. رابط ملف CSS الخاص بالنظام -->
<link rel="stylesheet" href="competition-style.css">
<!-- 🔥 3. رابط مكتبة الأسئلة -->
<script src="questions-library.js"></script>
حفظ
تحميل
مسح
</style>
<div class="bot-avatar">
<a class="fas fa-female"></a>
</div>
<div>
<div class="bot-name"> اللّٓه ويعلمكم</div>
<div class="bot-subtitle"> </div>
</div>
</div>
<div class="contact-info">
<i class="fas fa-phone-alt"></i> المطور :أميرالدين الحيمي
</div>
<!-- Chat Area -->
<div class="chat-container">
<div class="chat-messages" id="chatMessages">
<div class="bot-message">
السلام عليكم ورحمة الله وبركاته 🌹<br>
أنا ادارة الحور، أسعد بمحادثتك. كيف يمكنني مساعدتك اليوم؟
<div class="message-time">الآن</div>
<div class="message-actions">
<button class="action-btn" onclick="openCommentModal(this)">
<i class="far fa-comment-alt"></i>
</button>
<button class="action-btn" onclick="reactToMessage(this, '👍')">
<i class="far fa-thumbs-up"></i>
</button>
<button class="action-btn" onclick="reactToMessage(this, '❤️')">
<i class="far fa-heart"></i>
</button>
<button class="action-btn" onclick="reactToMessage(this, '😂')">
<i class="far fa-laugh"></i>
</button>
</div>
</div>
</div>
<!-- Side Panel -->
أنواع الردود السريعة
<div class="response-types-container" id="responseTypesContainer">
<!-- شبكة أفق<!-- ============================= -->
<div class="response-types-grid" id="responseTypes">
<button class="type-btn compact active" data-type="all" onclick="setResponseType('all')" title="كل الردود">
<span class="type-icon">📁</span>
<span class="type-text">الكل</span>
</button>
<button class="type-btn compact" data-type="moral" onclick="setResponseType('moral')" title="أخلاق وحكمة">
<span class="type-icon">💡</span>
<span class="type-text">أخلاق</span>
</button>
<button class="type-btn compact" data-type="story" onclick="setResponseType('story')" title="قصص وعبر">
<span class="type-icon">📖</span>
<span class="type-text">قصص</span>
</button>
<button class="type-btn compact" data-type="joke" onclick="setResponseType('joke')" title="نكت ومرح">
<span class="type-icon">😂</span>
<span class="type-text">نكت</span>
</button>
<button class="type-btn compact" data-type="advice" onclick="setResponseType('advice')" title="نصائح وإرشادات">
<span class="type-icon">🗣️</span>
<span class="type-text">نصائح</span>
</button>
<button class="type-btn compact" data-type="poem" onclick="setResponseType('poem')" title="شعر وأدب">
<span class="type-icon">✍️</span>
<span class="type-text">شعر</span>
</button>
<button class="type-btn compact" data-type="islamic" onclick="setResponseType('islamic')" title="دين التوحيد">
<span class="type-icon">🕌</span>
<span class="type-text">دين</span>
</button>
<button class="type-btn compact" data-type="science" onclick="setResponseType('science')" title="علوم ومعرفة">
<span class="type-icon">🔬</span>
<span class="type-text">علوم</span>
</button>
</div>
<!-- الإحصائيات تبقى كما هي -->
<div class="conversation-stats compact">
<!-- محتوى الإحصائيات -->
</div>
</div>
عدد رسائلك:
0
عدد ردود البوت:
1
الكلمات المرسلة:
0
مستوى الذكاء:
99%
<div class="copyright">
© 2023 شات حور - جميع الحقوق محفوظة<br>
هاتف المطور: 00967770249963
</div>
</div>
</div>
الكلمات الجاهزة (انقر للطي/الفرد)
👋 مرحبا
🤔 كيف حالك
📖 قصة
💡 نصيحة أخلاقية
😂 نكتة
🌹 عن الصبر
✍️ قصيدة
🙏 شكرا
🔤 ما اسمك
📅 كيف يومك
🕌 حديث
💎 حكمة
🧠 معلومة
💭 تفسير حلم
👩👦 عن الأم
🚀 نصيحة نجاح
🍲 وصفة
🏠 عن الوطن
😄 نكتة يمن
📚 قصة قصيرة
🤝 عن الصداقة
🏥 نصيحة صحية
🔬 حقيقة علمية
🤲 عن التعاون
💰 نصيحة مالية
🕊️ عن التسامح
⭐ قصة نجاح
📚 عن العلم
💖 نصيحة عاطفية
💼 عن العمل
🤣 نكتة مضحكة
🌈 عن الأمل
<div class="input-row">
<input type="text" id="messageInput" placeholder="اكتب رسالتك هنا العين..." autocomplete="off">
<div class="voice-input" id="voiceInput" title="سجل رسالة صوتية">
<i class="fas fa-microphone"></i>
</div>
<button class="send-btn" onclick="sendMessage()">
<i class="fas fa-paper-plane"></i> إرسال
</button>
</div>
</div>
<div class="comment-section">
<h4>أضف تعليقًا أو رد فعل:</h4>
<div class="emojis-container" id="emojisContainer">
<!-- سيتم ملؤها بالرموز التعبيرية -->
</div>
<textarea class="comment-input" id="commentInput" placeholder="اكتب تعليقك هنا..."></textarea>
<div style="display: flex; gap: 10px; margin-top: 10px;">
<button onclick="addComment()" style="flex: 1; padding: 10px; background: var(--primary-color); color: white; border: none; border-radius: 10px; cursor: pointer;">
<i class="fas fa-paper-plane"></i> إرسال التعليق
</button>
<button onclick="closeModal()" style="padding: 10px 20px; background: #ddd; border: none; border-radius: 10px; cursor: pointer;">
إلغاء
</button>
</div>
<div class="comments-list" id="commentsList">
<!-- سيتم ملؤها بالتعليقات -->
</div>
</div>
</div>
</div>
لا تيأسَنَّ من الحياة ولو كظُّمت .. فربما انفرجت الشدائد في الغدِ", "كن بلسماً إن صار دهرك أرقما .. واحلم إذا ما عابك الدهرُ وسلما
واحفظ لسانك إن نطقت ولا تكن .. مغرىً بالوقيعة إن قلتَ أو كَلِما", "إن الجمالَ جمالُ العلمِ والأدبْ .. ليس الجمالُ جمالَ الثوبِ والقلبْ
كم من قبيحٍ قبحُ الخلقِ أذهبَ ما .. يحوي من الجمالِ في ثوبٍ مُهَذَّبْ", "إذا المرءُ لا يرعاك إلا تكلفاً .. فدعه ولا تكثر عليه التأسفا
ففي الناس أبدال وفي الترك راحةٌ .. وفي القلب صبر للحبيب ولو جفا", "ولا خير في ودِّ امرئ متلوِّنٍ .. إذا الريح مالت مال حيث تميل
ما أكثر الإخوان حين تعدهم .. ولكنهم في النائبات قليل", "عش عزيزاً أو مت وأنت كريم .. بين طعن القنا وخفق البنود
لا تسأل المرء عن أخلاقه .. في وجهه ما ينطق به اللسان", "وطني لو شغلت بالخلد عنه .. نازعتني إليه في الخلد نفسي", "أماويَّ إن المال غادٍ ورائحٌ .. ويبقى من المال الأحاديث والذكر
أماويَّ إن المال يذهب نفعه .. ويبقى الذي قدَّمته من حسن الأثر", "لا تشكي للناس جرحاً أنت صاحبه .. لا يؤلم الجرح إلا من به ألم", "إذا أنت أكرمت الكريم ملكته .. وإن أنت أكرمت اللئيم تمردا", "ومن يجعل المعروف في غير أهله .. يكن حمده ذماً عليه ويندم", "ومن هاب أسباب المنايا ينلنه .. ولو رام أسباب السماء بسلم", "ومن لا يحب صعود الجبال .. يعش أبد الدهر بين الحفر", "إذا غامرت في شرف مروم .. فلا تقنع بما دون النجوم", "وما نيل المطالب بالتمني .. ولكن تؤخذ الدنيا غلابا", "وطني إن شغلت بالخلد عنه .. نازعتني إليه في الخلد نفسي", "يا ويح من يبني المجد على .. مال يجمع من حرام فيندم", "ذو العقل يشقى في النعيم بعقله .. وأخو الجهالة في الشقاوة ينعم", "لا تحسبن المجد تمراً أنت آكله .. لن تبلغ المجد حتى تلعق الصبرا", "إذا أنت لم تعرف لك القديم فضلاً .. فما أنت إلا حديث كل يوم", "وما الحسب الموروث غير وسام .. على صدر من لا يحسن الكلام", "إذا كنت في حاجة مرسلاً .. فأرسل حكيماً ولا توصه", "أحسن إلى الناس تستعبد قلوبهم .. فطالما استعبد الإنسانَ إحسان", "ولرب نازلة يضيق بها الفتى .. ذرعاً وعند الله منها المخرج", "إذا المرء أعيته المروءة ناشئاً .. فمطلبها كهلاً عليه عسير", "ومن لم يذق مر التعلم ساعة .. تجرع ذل الجهل طوال حياته", "ولو أن الحياة تبقى لحيٍ .. لعددنا أضلنا الشجعانا", "ولا خير في ود امرئ متلون .. إذا الريح مالت مال حيث تميل", "إذا القوم قالوا من فتى خلت أنني .. عنيت فلم أكسل ولم أتكاسل", "ألم تر أن السيف ينقص قدره .. إذا قيل إن السيف أمضى من العصا" ], // إسلاميات (30 رداً) islamic: [ "الله لا يغير ما بقوم حتى يغيروا ما بأنفسهم.", "إن الله مع الصابرين.", "من توكل على الله فهو حسبه.", "اذكروني أذكركم.", "الصلاة نور.", "الحياء من الإيمان.", "الطهور شطر الإيمان.", "إنما الأعمال بالنيات.", "الكلمة الطيبة صدقة.", "تبسمك في وجه أخيك صدقة.", "اتق الله حيثما كنت.", "خيركم من تعلم القرآن وعلمه.", "الدين النصيحة.", "لا يؤمن أحدكم حتى يحب لأخيه ما يحب لنفسه.", "المسلم من سلم الناس من لسانه ويده.", "أكمل المؤمنين إيماناً أحسنهم خلقاً.", "إن الله جميل يحب الجمال.", "اللهم إني أسألك علماً نافعاً.", "من سلك طريقاً يلتمس فيه علماً سهل الله له طريقاً إلى الجنة.", "طلب العلم فريضة على كل مسلم.", "خير الناس أنفعهم للناس.", "الدنيا سجن المؤمن وجنة الكافر.", "أعقلها وتوكل.", "إنما يحفظ الله من حفظه.", "من عظم شعائر الله فإنها من تقوى القلوب.", "وقل رب زدني علماً.", "وما توفيقي إلا بالله.", "إن مع العسر يسراً.", "فpاصبر إن وعد الله حق.", "الله لا يضيع أجر المحسنين." ], // علوم ومعرفة (35 حقيقة) science: [ "الضوء يستغرق 8 دقائق و20 ثانية للوصول من الشمس إلى الأرض.", "يحتوي جسم الإنسان على ما يكفي من الحديد لصنع مسمار طوله 7.5 سم.", "قلب الإنسان ينبض حوالي 100 ألف مرة في اليوم.", "الحوت الأزرق هو أكبر حيوان عاش على الأرض، حيث يصل وزنه إلى 200 طن.", "العسل هو الطعام الوحيد الذي لا يفسد.", "الذبابة ترفرف بجناحيها حوالي 200 مرة في الثانية.", "الفراشة تتذوق الطعام بأقدامها.", "الفيل هو الحيوان الوحيد الذي لا يستطيع القفز.", "السلحفاة يمكنها العيش لمدة تصل إلى 150 سنة.", "الكركم من أقوى المضادات الطبيعية للالتهابات.", "الليمون يحتوي على فيتامين C أكثر من البرتقال.", "التمر لا يحتوي على أي كوليسترول.", "الزنجبيل يساعد في تخفيف آلام المفاصل.", "العسل يعالج السعال أفضل من بعض الأدوية.", "القراءة لمدة 6 دقائق تخفض التوتر بنسبة 68٪.", "المشي يومياً يقلل خطر الإصابة بأمراض القلب.", "النوم الكافي يقوي الذاكرة.", "شرب الماء الدافئ مع الليمون في الصباح ينقي الجسم.", "الضحك يخفف الألم ويقوي المناعة.", "التأمل يحسن التركيز ويقلل القلق.", "الكتابة باليد تنشط الدماغ أكثر من الكتابة على الكمبيوتر.", "اللون الأزرق يقلل الشهية.", "الموز يحتوي على مادة تحسن المزاج.", "الشوكولاتة الداكنة تقوي الذاكرة.", "التوت يحسن النظر.", "السبانخ تزيد قوة العضلات.", "الثوم يقوي جهاز المناعة.", "الجزر يقوي النظر.", "الأسماك تزيد الذكاء.", "المكسرات تقوي الذاكرة.", "الزيتون يخفض الكوليسترول.", "الرمان ينقي الدم.", "الخيار يرطب الجسم.", "البطيخ يحتوي على 92٪ ماء.", "الأناناس يساعد على الهضم." ], // ردود عامة (40 رداً) general: [ "حيا بك! أسعد الله أوقاتك بكل خير.", "أهلاً وسهلاً، كيف يمكنني مساعدتك اليوم؟", "سعيد جداً بتواصلك معي، أنا حور العين جاهز للرد على استفساراتك.", "أتمنى أن تكون في أفضل حال، كيف يمكنني إسعادك اليوم؟", "الحمد لله أنا بخير، شكراً لسؤالك. وأنت كيف حالك؟", "شكراً لك على هذه الكلمات الطيبة، أنا أيضاً سعيد بالحديث معك.", "لا شكر على واجب، أنا هنا لخدمتك ومساعدتك.", "أهلاً بعودتك، لقد افتقدتك! كيف كانت أمورك؟", "يومك سعيد بإذن الله، وأتمنى لك التوفيق في جميع أعمالك.", "الله يسعدك ويوفقك، شكراً على محادثتك الطيبة.", "مرحباً بعودتك! هل لديك جديد تود مشاركته؟", "أهلاً وسهلاً بك مجدداً، سررت برؤيتك.", "كيف حال قلبك اليوم؟ أتمنى أن يكون مليئاً بالسعادة.", "الحمد لله على سلامتك، فرحت لرؤيتك.", "أتمنى أن يكون يومك جميلاً كما تخيلت.", "سعيد بسماع صوتك، كيف أمورك؟", "مرحباً بك في أي وقت، أنا هنا لأجلك.", "أهلاً بطل الود والكرم، كيف حالك؟", "سررت بتواصلك، هل هناك شيء معين تود الحديث عنه؟", "مرحباً بك في عالم الحور العين، مكانك معنا.", "أهلاً وسهلاً بك بين إخوانك.", "الحمد لله على اللقاء، كيف تقضي يومك؟", "مرحباً بعبق الورد، كيف حال الورد؟", "أهلاً بمن أشرقت الدنيا بقدومه.", "سررت بلقائك، هل تود أن نخوض في حديث ممتع؟", "مرحباً بك يا صديقي، كيف حالك اليوم؟", "أهلاً وسهلاً بك في أي وقت تشاء.", "الحمد لله على السلامة، كيف الحال؟", "مرحباً بك بعد الغياب، اشتقنا لحديثك.", "أهلاً بمن يجلب السعادة معه.", "سررت برؤيتك، هل جربت شيئاً جديداً اليوم؟", "مرحباً بك في حديثنا اليومي.", "أهلاً وسهلاً بك يا قرة العين.", "الحمد لله على اللقاء، هل لديك قصة ترويها؟", "مرحباً بك بعد الفراق، كيف كنت؟", "أهلاً بمن يضيء المكان بحضوره.", "سررت بلقائك، هل تريد أن نبدأ حديثاً جديداً؟", "مرحباً بك في حديقة الحديث.", "أهلاً وسهلاً بك بين الأحبة.", "الحمد لله على هذا اللقاء الطيب." ] }; // إحصائيات المحادثة let conversationStats = { userMessages: 0, botMessages: 1, // الرسالة الترحيبية الأولى wordsSent: 0, lastResponses: [], currentResponseType: 'all', isQuickActionsCollapsed: false, isResponseTypesCollapsed: false }; // تخزين التعليقات والتفاعلات let messageComments = {}; let messageReactions = {}; // تهيئة العناصر const chatMessages = document.getElementById('chatMessages'); const messageInput = document.getElementById('messageInput'); const quickActions = document.getElementById('quickActions'); const quickActionsHeader = document.getElementById('quickActionsHeader'); const responseTypes = document.getElementById('responseTypes'); const responseTypesHeader = document.getElementById('responseTypesTitle'); // تم التصحيح هنا const responseTypesContainer = document.getElementById('responseTypesContainer'); const commentModal = document.getElementById('commentModal'); const emojisContainer = document.getElementById('emojisContainer'); const commentsList = document.getElementById('commentsList'); const modalMessageContent = document.getElementById('modalMessageContent'); const commentInput = document.getElementById('commentInput'); let currentMessageElement = null; let currentMessageId = null; // تهيئة الرموز التعبيرية const emojis = ['😀', '😃', '😄', '😁', '😆', '😅', '😂', '🤣', '😊', '😇', '🙂', '🙃', '😉', '😌', '😍', '🥰', '😘', '😗', '😙', '😚', '😋', '😛', '😝', '😜', '🤪', '🤨', '🧐', '🤓', '😎', '🤩', '🥳', '😏', '😒', '😞', '😔', '😟', '😕', '🙁', '
التاريخ: ${new Date().toLocaleDateString('ar-SA')}
`); currentChat.forEach(msg => { printWindow.document.write(`
${msg.sender === 'user' ? 'أنت' : 'شات الحور'}:
`);
});
printWindow.document.write(`
${msg.text}
${msg.time}
تم الإنشاء بواسطة شات الحور - 00967770249963
`); // ==================== نظام المراسلة على الشبكة المحلية ==================== printWindow.document.close(); printWindow.print(); } // تبديل طي/فرد قسم أنواع الردود // ==================== قسم الطي/الفرد للردود والإحصائيات ==================== // 1. انتظر حتى يتم تحميل الصفحة بالكامل document.addEventListener('DOMContentLoaded', function() { // 2. عرّف العناصر const responseTypesHeader = document.getElementById('responseTypesTitle'); const responseTypesContainer = document.getElementById('responseTypesContainer'); // 3. تحقق من وجود العناصر if (!responseTypesHeader || !responseTypesContainer) { console.error("❌ عناصر قسم الردود غير موجودة"); return; } console.log("✅ تم العثور على عناصر قسم الردود والإحصائيات"); // 4. دالة الطي/الفرد function toggleResponseTypes() { console.log("🖱️ تم النقر على قسم الردود والإحصائيات"); // تحقق إذا كان مطوياً const isCollapsed = responseTypesContainer.classList.contains('collapsed'); if (isCollapsed) { // فتح القسم responseTypesContainer.classList.remove('collapsed'); responseTypesHeader.classList.remove('collapsed'); // تحديث الأيقونة const icon = responseTypesHeader.querySelector('i'); if (icon) { icon.style.transform = 'rotate(0deg)'; } console.log("📖 تم فتح قسم الردود والإحصائيات"); } else { // طي القسم responseTypesContainer.classList.add('collapsed'); responseTypesHeader.classList.add('collapsed'); // تحديث الأيقونة const icon = responseTypesHeader.querySelector('i'); if (icon) { icon.style.transform = 'rotate(-90deg)'; } console.log("📕 تم طي قسم الردود والإحصائيات"); } // حفظ الحالة في (اختياري) try { localStorage.setItem('responseTypesCollapsed', !isCollapsed); } catch (e) { console.warn("${time}
${new Date().toLocaleTimeString('ar-SA', {
hour: '2-digit',
minute: '2-digit'
})}
${audioElement}
`;
chatMessages.appendChild(div);
chatMessages.scrollTop = chatMessages.scrollHeight;
// تحديث الإحصائيات
conversationStats.userMessages++;
updateStats();
// حفظ الرسالة الصوتية مؤقتاً
saveVoiceMessageToStorage(voiceId, audioBlob);
// إضافة رد تلقائي
setTimeout(() => {
const responses = [
"🎧 استمعت لرسالتك الصوتية! كيف يمكنني مساعدتك؟",
"🔊 تلقيت رسالتك الصوتية. هل يمكنك إعادة صياغتها كتابياً إذا أردت؟",
"🎤 شكراً للرسالة الصوتية! أنا هنا للإجابة على استفساراتك.",
"👂 سمعت رسالتك. هل هناك شيء محدد تريد مناقشته؟",
"💬 استمعت للصوت. هل يمكنني مساعدتك في شيء معين؟"
];
const response = responses[Math.floor(Math.random() * responses.length)];
addMessage(response, 'bot');
}, 1500);
console.log('📤 تم إرسال الرسالة الصوتية');
}
// حفظ الرسالة الصوتية في التخزين المؤقت
function saveVoiceMessageToStorage(id, blob) {
try {
// تحويل blob إلى base64 للتخزين
const reader = new FileReader();
reader.onloadend = function() {
const base64data = reader.result;
const voiceMessage = {
id: id,
data: base64data,
timestamp: new Date().toISOString(),
type: 'audio/webm'
};
// حفظ في localStorage
const savedVoices = JSON.parse(localStorage.getItem('voiceMessages') || '[]');
savedVoices.push(voiceMessage);
// الاحتفاظ بآخر 20 رسالة صوتية فقط
if (savedVoices.length > 20) {
savedVoices.shift();
}
localStorage.setItem('voiceMessages', JSON.stringify(savedVoices));
console.log('💾 تم حفظ الرسالة الصوتية');
};
reader.readAsDataURL(blob);
} catch (error) {
console.error('❌ خطأ في حفظ الرسالة الصوتية:', error);
}
}
// تنزيل الرسالة الصوتية
function downloadVoiceMessage(id, url) {
const a = document.createElement('a');
a.href = url;
a.download = `رسالة_صوتية_${new Date().toLocaleDateString('ar-SA').replace(/\//g, '-')}.webm`;
a.click();
addMessage('📥 تم بدء تنزيل الرسالة الصوتية.', 'bot');
}
// حذف الرسالة الصوتية
function deleteVoiceMessage(id) {
const voiceElement = document.getElementById(id);
if (voiceElement && confirm('هل تريد حذف هذه الرسالة الصوتية؟')) {
voiceElement.closest('.message').remove();
// حذف من localStorage
const savedVoices = JSON.parse(localStorage.getItem('voiceMessages') || '[]');
const updatedVoices = savedVoices.filter(voice => voice.id !== id);
localStorage.setItem('voiceMessages', JSON.stringify(updatedVoices));
addMessage('🗑️ تم حذف الرسالة الصوتية.', 'bot');
}
}
// تشغيل كل الرسائل الصوتية تلقائياً
function playAllVoiceMessages() {
const audioElements = document.querySelectorAll('audio');
audioElements.forEach(audio => {
audio.play().catch(e => console.log('تعذر تشغيل الصوت:', e));
});
}
// حدث النقر على زر الميكروفون
voiceInput.addEventListener('click', async function() {
if (!isRecording) {
// بدء التسجيل
const started = await startRecording();
if (started) {
addMessage('🎤 جاري التسجيل... تحدث الآن.', 'bot');
}
} else {
// إيقاف التسجيل
stopRecording();
addMessage('⏹️ تم إوقف التسجيل.', 'bot');
}
});
// إضافة ردود فعل للتسجيل
voiceInput.addEventListener('mouseenter', function() {
if (!isRecording) {
this.style.transform = 'scale(1.1)';
}
});
voiceInput.addEventListener('mouseleave', function() {
if (!isRecording) {
this.style.transform = 'scale(1)';
}
});
// الكشف عن المتصفحات التي تدعم التسجيل الصوتي
function checkRecordingSupport() {
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
addMessage('')[0];
modalMessageContent.innerHTML = `
/g, '\n').replace(/<[^>]*>/g, ''), sender: sender, time: time, timestamp: new Date().toISOString() }); // حفظ في localStorage أيضاً localStorage.setItem('chatBackup', JSON.stringify(currentChat)); } // تحديث دالة addMessage لتتبع الرسائل // ابحث عن دالة addMessage الأصلية وأضف هذا السطر في نهايتها: // trackMessage(text, sender, time); // دالة لحفظ المحادثة في ملف txt function saveChatToTxt() { if (currentChat.length === 0) { alert('لا توجد محادثة لحفظها!'); return; } let chatContent = "=== محادثة شات الحور ===\n"; chatContent += `التاريخ: ${new Date().toLocaleDateString('ar-SA')}\n`; chatContent += `الوقت: ${new Date().toLocaleTimeString('ar-SA')}\n`; chatContent += "=".repeat(40) + "\n\n"; currentChat.forEach((msg, index) => { const senderName = msg.sender === 'user' ? 'أنت' : 'شات الحور'; chatContent += `[${msg.time}] ${senderName}:\n`; chatContent += `${msg.text}\n`; chatContent += "-".repeat(30) + "\n"; }); chatContent += "\n" + "=".repeat(40) + "\n"; chatContent += "تم الإنشاء بواسطة شات الحور الذكي\n"; chatContent += "رقم المطور: 00967770249963\n"; // إنشاء ملف وتنزيله const blob = new Blob([chatContent], { type: 'text/plain;charset=utf-8' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `محادثة_شات_االحور_${new Date().toLocaleDateString('ar-SA').replace(/\//g, '-')}.txt`; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); // إضافة رسالة تأكيد addMessage(`💾 تم حفظ المحادثة في ملف نصي. يمكنك العثور عليه في مجلد التنزيلات باسم: ${a.download}`, 'bot'); } // دالة لتحميل محادثة من ملف function loadChatFromTxt() { const input = document.createElement('input'); input.type = 'file'; input.accept = '.txt'; input.onchange = function(event) { const file = event.target.files[0]; if (!file) return; const reader = new FileReader(); reader.onload = function(e) { try { const content = e.target.result; displayLoadedChat(content); } catch (error) { alert('حدث خطأ في قراءة الملف: ' + error.message); } }; reader.readAsText(file); }; input.click(); } // عرض المحادثة المحملة function displayLoadedChat(content) { // مسح المحادثة الحالية clearCurrentChat(); // إضافة رسالة تأكيد addMessage('📂 تم تحميل محادثة من ملف نصي. جاري عرضها...', 'bot'); // تقسيم المحتوى وعرضه const lines = content.split('\n'); let currentSender = ''; let currentText = ''; lines.forEach(line => { if (line.includes('أنت:')) { // حفظ الرسالة السابقة إذا كانت موجودة if (currentText && currentSender) { setTimeout(() => { addMessage(currentText, currentSender === 'أنت' ? 'user' : 'bot'); }, 500); } currentSender = 'أنت'; currentText = line.replace('أنت:', '').trim(); } else if (line.includes('شات العين:')) { if (currentText && currentSender) { setTimeout(() => { addMessage(currentText, currentSender === 'أنت' ? 'user' : 'bot'); }, 500); } currentSender = 'شات العين'; currentText = line.replace('شات الحور:', '').trim(); } else if (line.trim() && !line.includes('===') && !line.includes('---')) { currentText += '\n' + line.trim(); } }); // إضافة آخر رسالة if (currentText && currentSender) { setTimeout(() => { addMessage(currentText, currentSender === 'أنت' ? 'user' : 'bot'); }, 500); } setTimeout(() => { addMessage('✅ تم تحميل المحادثة بنجاح!', 'bot'); }, 1000); } // دالة لمسح المحادثة الحالية function clearCurrentChat() { if (confirm('هل تريد مسح المحادثة الحالية؟ سيتم حفظها أولاً تلقائياً.')) { // حفظ تلقائي قبل المسح saveChatToTxt(); // مسح العرض const chatMessages = document.getElementById('chatMessages'); chatMessages. innerHTML = ''; // إعادة إضافة الرسالة الترحيبية const welcomeMsg = ` السلام عليكم ورحمة الله وبركاته 🌹
أنا ادارة العين، أسعد بمحادثتك. كيف يمكنني مساعدتك اليوم؟
`;
const div = document.createElement('div');
div.className = 'bot-message';
div.innerHTML = welcomeMsg;
chatMessages.appendChild(div);
// إعادة تعيين currentChat
currentChat = [];
localStorage.removeItem('chatBackup');
// تحديث الإحصائيات
conversationStats.userMessages = 0;
conversationStats.botMessages = 1;
conversationStats.wordsSent = 0;
updateStats();
}
}
// دالة لحفظ تلقائي كل 10 رسائل
function autoSaveIfNeeded() {
if (currentChat.length > 0 && currentChat.length % 10 === 0) {
const autoSaveBtn = document.createElement('button');
autoSaveBtn.innerHTML = '💾 حفظ تلقائي';
autoSaveBtn.style.cssText = `
position: fixed;
bottom: 100px;
right: 20px;
background: linear-gradient(to right, #4CAF50, #2E7D32);
color: white;
border: none;
padding: 10px 15px;
border-radius: 20px;
cursor: pointer;
z-index: 1000;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
font-size: 12px;
`;
autoSaveBtn.onclick = saveChatToTxt;
document.body.appendChild(autoSaveBtn);
setTimeout(() => {
if (autoSaveBtn.parentNode) {
autoSaveBtn.parentNode.removeChild(autoSaveBtn);
}
}, 5000);
}
}
// تحميل النسخة الاحتياطية عند بدء التشغيل
window.addEventListener('load', function() {
const backup = localStorage.getItem('chatBackup');
if (backup) {
const loadBackup = confirm('تم العثور على محادثة محفوظة. هل تريد استعادتها؟');
if (loadBackup) {
try {
currentChat = JSON.parse(backup);
// عرض رسالة
addMessage('📂 تم استعادة المحادثة المحفوظة!', 'bot');
} catch (e) {
console.error('خطأ في تحميل النسخة الاحتياطية:', e);
}
}
}
});
// ==================== نظام المسابقات والجوائز والترقيات ====================
// competition-system.js
// نظام المسابقات المتكامل
window.competitionSystem = {
// الحالة الحالية
state: {
isCompetitionOpen: false,
currentQuiz: null,
currentQuestion: 0,
score: 0,
coins: parseInt(localStorage.getItem('competition_coins')) || 3,
medals: JSON.parse(localStorage.getItem('competition_medals')) || [],
selectedAnswer: null,
timer: null,
timeLeft: 0,
results: [],
totalQuestions: 0,
correctAnswers: 0,
wrongAnswers: 0,
skippedAnswers: 0
},
// مستويات الميداليات
medalLevels: [
{ threshold: 9, name: "حديد", icon: "🛡️", class: "medal-iron" },
{ threshold: 18, name: "برونزي", icon: "🥉", class: "medal-bronze" },
{ threshold: 27, name: "فضي", icon: "🥈", class: "medal-silver" },
{ threshold: 36, name: "ذهبي", icon: "🥇", class: "medal-gold" },
{ threshold: 45, name: "بلاتيني", icon: "🏆", class: "medal-platinum" },
{ threshold: 54, name: "ماسي", icon: "💎", class: "medal-diamond" },
{ threshold: 63, name: "الغازي", icon: "👑", class: "medal-conqueror" }
],
// تهيئة النظام
init: function() {
console.log("🎯 نظام المسابقات جاهز!");
this.updateMedalDisplay();
},
// فتح نظام المسابقات
openCompetitionSystem: function() {
this.state.isCompetitionOpen = true;
this.renderCompetitionModal();
},
// إغلاق نظام المسابقات
closeCompetitionSystem: function() {
this.state.isCompetitionOpen = false;
this.closeModal();
},
// عرض نافذة المسابقة
renderCompetitionModal: function() {
const modal = document.createElement('div');
modal.className = 'modal-overlay competition-modal active';
modal.id = 'competitionModal';
modal.innerHTML = `
`;
document.body.appendChild(modal);
this.renderCompetitionSelection();
this.addEventListeners();
},
// عرض قائمة المسابقات
renderCompetitionSelection: function() {
const container = document.getElementById('competitionSelection');
if (!container) return;
let html = '';
html += '
`;
}
document.getElementById('resultContainer').innerHTML = html;
},
// عرض النتائج التفصيلية
showDetailedResults: function() {
let html = '';
this.state.results.forEach((result, index) => {
const question = this.state.currentQuiz.questions[index];
const letters = ['أ', 'ب', 'ج', 'د'];
html += `
`;
});
html += `
العودة
`;
document.getElementById('resultContainer').innerHTML = html;
},
// عرض لوحة المتصدرين
showLeaderboard: function() {
document.getElementById('competitionSelection').style.display = 'none';
document.getElementById('leaderboardContainer').style.display = 'block';
let leaderboard = JSON.parse(localStorage.getItem('competition_leaderboard')) || [];
// إضافة المستخدم الحالي إذا لم يكن موجود
const currentUser = {
name: localStorage.getItem('player_name') || 'اللاعب',
coins: this.state.coins,
medal: this.getCurrentMedal().name,
score: this.state.score,
date: new Date().toLocaleDateString('ar-SA')
};
if (!leaderboard.some(player => player.name === currentUser.name)) {
leaderboard.push(currentUser);
}
// ترتيب اللاعبين حسب النقاط
leaderboard.sort((a, b) => b.coins - a.coins);
let html = `
`;
leaderboard.forEach((player, index) => {
html += `
`;
});
html += `
`;
document.body.appendChild(modal);
this.renderCompetitionGrid();
},
// عرض شبكة المسابقات
renderCompetitionGrid: function() {
const grid = document.getElementById('competitionGrid');
if (!grid) return;
let html = '';
for (const [key, quiz] of Object.entries(this.questionLibrary)) {
const isCompleted = this.userState.completedQuizzes.includes(key);
const completionRate = isCompleted ? '100%' : '0%';
html += `
`;
}
grid.innerHTML = html;
},
// بدء المسابقة
startQuiz: function(quizType) {
const quiz = this.questionLibrary[quizType];
if (!quiz) return;
document.getElementById('competitionSelection').style.display = 'none';
document.getElementById('questionContainer').style.display = 'block';
// تهيئة حالة المسابقة
this.currentQuiz = {
type: quizType,
questions: [...quiz.questions],
currentQuestionIndex: 0,
score: 0,
correctAnswers: 0,
wrongAnswers: 0,
startTime: Date.now()
};
// خلط الأسئلة
this.shuffleQuestions();
// عرض السؤال الأول
this.showQuestion();
// بدء المؤقت
this.startTimer();
},
// خلط الأسئلة
shuffleQuestions: function() {
if (!this.currentQuiz) return;
for (let i = this.currentQuiz.questions.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[this.currentQuiz.questions[i], this.currentQuiz.questions[j]] =
[this.currentQuiz.questions[j], this.currentQuiz.questions[i]];
}
},
// عرض السؤال
showQuestion: function() {
if (!this.currentQuiz) return;
const container = document.getElementById('questionContainer');
const question = this.currentQuiz.questions[this.currentQuiz.currentQuestionIndex];
const questionNumber = this.currentQuiz.currentQuestionIndex + 1;
const totalQuestions = this.currentQuiz.questions.length;
const progress = (questionNumber / totalQuestions) * 100;
container.innerHTML = `
`;
this.resetTimer();
},
// اختيار الإجابة
selectAnswer: function(selectedIndex) {
const question = this.currentQuiz.questions[this.currentQuiz.currentQuestionIndex];
const isCorrect = selectedIndex === question.correct;
const optionButtons = document.querySelectorAll('.option-btn');
const nextBtn = document.getElementById('nextBtn');
const explanationBox = document.getElementById('explanationBox');
const explanationText = document.getElementById('explanationText');
// تلوين الإجابات
optionButtons.forEach((btn, index) => {
btn.disabled = true;
if (index === question.correct) {
btn.classList.add('correct');
} else if (index === selectedIndex && !isCorrect) {
btn.classList.add('wrong');
}
});
// تسجيل النتيجة
if (isCorrect) {
this.currentQuiz.score += question.points;
this.currentQuiz.correctAnswers++;
this.showNotification(`إجابة صحيحة! +${question.points} نقطة`, 'success');
} else {
this.currentQuiz.wrongAnswers++;
this.showNotification('إجابة خاطئة!', 'error');
}
// عرض الشرح
if (explanationText) {
explanationText.textContent = question.explanation;
explanationBox.style.display = 'block';
}
// إظهار زر التالي
if (nextBtn) {
nextBtn.style.display = 'block';
}
// إيقاف المؤقت
clearInterval(this.timerInterval);
},
// تخطي السؤال
skipQuestion: function() {
if (this.userState.coins < 5) {
this.showNotification('ليس لديك عملات كافية للتخطي!', 'error');
return;
}
this.userState.coins -= 5;
this.currentQuiz.wrongAnswers++;
this.updateDisplay();
this.saveUserState();
this.nextQuestion();
},
// السؤال التالي
nextQuestion: function() {
this.currentQuiz.currentQuestionIndex++;
if (this.currentQuiz.currentQuestionIndex < this.currentQuiz.questions.length) {
this.showQuestion();
} else {
this.showResults();
}
},
// عرض النتائج
showResults: function() {
document.getElementById('questionContainer').style.display = 'none';
document.getElementById('resultContainer').style.display = 'block';
const container = document.getElementById('resultContainer');
const totalTime = Math.floor((Date.now() - this.currentQuiz.startTime) / 1000);
const accuracy = (this.currentQuiz.correctAnswers / this.currentQuiz.questions.length) * 100;
// حساب المكافآت
const coinsEarned = Math.floor(this.currentQuiz.score * 0.5);
const pointsEarned = this.currentQuiz.score;
// تحديث حالة المستخدم
this.userState.coins += coinsEarned;
this.userState.points += pointsEarned;
this.userState.completedQuizzes.push(this.currentQuiz.type);
// التحقق من الترقية
this.checkLevelUp();
// حفظ الحالة
this.saveUserState();
container.innerHTML = `
`;
},
// عرض الجوائز
showRewards: function() {
this.showSection('rewardsContainer');
const container = document.getElementById('rewardsContainer');
const rewards = [
{ id: 1, name: "الميدالية الذهبية", icon: "🥇", cost: 1000, description: "للخبراء" },
{ id: 2, name: "الميدالية الفضية", icon: "🥈", cost: 500, description: "للمتقدمين" },
{ id: 3, name: "الميدالية البرونزية", icon: "🥉", cost: 250, description: "للمبتدئين" },
{ id: 4, name: "شهادة التميز", icon: "📜", cost: 2000, description: "للحفاظ" },
{ id: 5, name: "درع التفوق", icon: "🛡️", cost: 1500, description: "للمتميزين" }
];
container.innerHTML = `
`;
},
// شراء جائزة
buyReward: function(rewardId) {
// محاكاة عملية الشراء
this.showNotification('تم شراء الجائزة بنجاح!', 'success');
this.updateDisplay();
},
// المكافأة اليومية
checkDailyReward: function() {
const today = new Date().toDateString();
if (this.userState.lastPlayDate !== today) {
this.userState.dailyStreak = this.userState.lastPlayDate ?
(new Date(today) - new Date(this.userState.lastPlayDate) === 86400000 ?
this.userState.dailyStreak + 1 : 1) : 1;
this.userState.lastPlayDate = today;
this.saveUserState();
}
},
claimDailyReward: function() {
const reward = (this.userState.dailyStreak * 10) + 50;
this.userState.coins += reward;
this.saveUserState();
this.updateDisplay();
this.showNotification(`+${reward} عملة! استمرارية ${this.userState.dailyStreak} يوم`, 'success');
},
// التحقق من الترقية
checkLevelUp: function() {
const oldLevel = this.userState.level;
this.userState.level = Math.floor(this.userState.points / 1000) + 1;
if (this.userState.level > oldLevel) {
const coinsReward = this.userState.level * 100;
this.userState.coins += coinsReward;
this.showNotification(`مبروك! ترقية للمستوى ${this.userState.level}! +${coinsReward} عملة`, 'success');
}
},
// مشاركة النتائج
shareResults: function() {
const text = `حصلت على ${this.currentQuiz.score} نقطة في المسابقة الإسلامية!`;
if (navigator.share) {
navigator.share({
title: 'نتيجة المسابقة الإسلامية',
text: text,
url: window.location.href
});
} else {
navigator.clipboard.writeText(text);
this.showNotification('تم نسخ النتيجة!', 'info');
}
},
// تصدير البيانات
exportData: function() {
const data = {
userState: this.userState,
exportDate: new Date().toISOString(),
achievements: this.getAchievements()
};
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `islamic_competition_${new Date().toISOString().slice(0,10)}.json`;
a.click();
this.showNotification('تم تصدير بياناتك!', 'success');
},
// الحصول على الإنجازات
getAchievements: function() {
return {
completedQuizzes: this.userState.completedQuizzes.length,
totalPoints: this.userState.points,
currentLevel: this.userState.level,
medalsEarned: this.userState.medals.length,
dailyStreak: this.userState.dailyStreak
};
},
// حفظ حالة المستخدم
saveUserState: function() {
localStorage.setItem('islamic_coins', this.userState.coins);
localStorage.setItem('islamic_points', this.userState.points);
localStorage.setItem('islamic_level', this.userState.level);
localStorage.setItem('islamic_medals', JSON.stringify(this.userState.medals));
localStorage.setItem('completed_quizzes', JSON.stringify(this.userState.completedQuizzes));
localStorage.setItem('daily_streak', this.userState.dailyStreak);
localStorage.setItem('last_play_date', this.userState.lastPlayDate);
this.updateDisplay();
},
// تحديث العرض
updateDisplay: function() {
const coinCount = document.getElementById('coinCount');
const pointCount = document.getElementById('pointCount');
if (coinCount) coinCount.textContent = this.userState.coins;
if (pointCount) pointCount.textContent = this.userState.points;
},
// تحميل إحصائيات المستخدم
loadUserStats: function() {
console.log('📊 إحصائيات المستخدم:', this.userState);
},
// إظهار القسم
showSection: function(sectionId) {
const sections = ['competitionSelection', 'questionContainer', 'resultContainer',
'leaderboardContainer', 'rewardsContainer'];
sections.forEach(id => {
const element = document.getElementById(id);
if (element) {
element.style.display = id === sectionId ? 'block' : 'none';
}
});
},
// إغلاق المسابقة
closeCompetition: function() {
const modal = document.getElementById('competitionModal');
if (modal) modal.remove();
if (this.timerInterval) clearInterval(this.timerInterval);
},
// إظهار إشعار
showNotification: function(message, type = 'info') {
const notification = document.createElement('div');
notification.className = `competition-notification ${type}`;
notification.innerHTML = `
${message}
`;
document.body.appendChild(notification);
setTimeout(() => {
notification.remove();
}, 3000);
}
};
// تهيئة النظام عند تحميل الصفحة
window.addEventListener('load', function() {
IslamicCompetition.init();
// إضافة زر المسابقات إذا لم يكن موجوداً
if (!document.querySelector('.competition-btn')) {
const compBtn = document.createElement('button');
compBtn.className = 'competition-btn';
compBtn.innerHTML = ' المسابقات الإسلامية';
compBtn.onclick = () => IslamicCompetition.openCompetition();
document.body.appendChild(compBtn);
}
});
// دالة لفتح المسابقات من الأزرار الأخرى
function openCompetition() {
IslamicCompetition.openCompetition();
}
</script>
<style>
/* أنماط نظام المسابقات */
.competition-btn {
position: fixed;
bottom: 120px;
right: 20px;
background: linear-gradient(135deg, #d4af37 0%, #b8941f 100%);
color: white;
padding: 12px 24px;
border-radius: 25px;
border: none;
cursor: pointer;
box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
z-index: 1000;
font-size: 14px;
display: flex;
align-items: center;
gap: 8px;
animation: float 3s ease-in-out infinite;
}
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-5px); }
}
.competition-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.95);
display: flex;
justify-content: center;
align-items: center;
z-index: 10010;
backdrop-filter: blur(10px);
}
.competition-container {
background: linear-gradient(135deg, #1a5e25 0%, #0d4d1a 100%);
width: 95%;
max-width: 900px;
max-height: 90vh;
border-radius: 20px;
overflow: hidden;
border: 3px solid #d4af37;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.competition-header {
background: rgba(0, 0, 0, 0.3);
padding: 20px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 2px solid rgba(212, 175, 55, 0.3);
}
.competition-header h2 {
color: #d4af37;
margin: 0;
font-size: 24px;
}
.competition-stats {
display: flex;
gap: 20px;
}
.stat-item {
background: rgba(255, 255, 255, 0.1);
padding: 8px 15px;
border-radius: 15px;
display: flex;
align-items: center;
gap: 8px;
color: white;
}
.close-btn {
background: rgba(255, 255, 255, 0.1);
border: none;
color: white;
width: 40px;
height: 40px;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.competition-body {
padding: 20px;
max-height: 60vh;
overflow-y: auto;
}
.competition-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 20px;
margin-top: 20px;
}
.competition-card {
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
padding: 20px;
cursor: pointer;
transition: all 0.3s;
border: 2px solid transparent;
}
.competition-card:hover {
border-color: #d4af37;
transform: translateY(-5px);
background: rgba(212, 175, 55, 0.1);
}
.competition-card.completed {
border-color: #4CAF50;
}
.competition-icon {
font-size: 40px;
margin-bottom: 15px;
text-align: center;
}
.competition-info h4 {
color: white;
margin: 0 0 10px 0;
}
.competition-info p {
color: rgba(255, 255, 255, 0.7);
font-size: 14px;
margin: 0 0 15px 0;
}
.competition-meta {
display: flex;
justify-content: space-between;
font-size: 12px;
color: rgba(255, 255, 255, 0.5);
margin-bottom: 10px;
}
.progress-bar {
height: 6px;
background: rgba(255, 255, 255, 0.1);
border-radius: 3px;
overflow: hidden;
margin-top: 10px;
}
.progress-fill {
height: 100%;
background: #4CAF50;
transition: width 0.3s;
}
.completed-badge {
background: #4CAF50;
color: white;
padding: 3px 10px;
border-radius: 10px;
font-size: 12px;
display: inline-block;
margin-top: 10px;
}
/* أنماط الأسئلة */
.question-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
color: white;
}
.question-progress {
flex: 1;
}
.timer-display {
background: rgba(0, 0, 0, 0.3);
padding: 8px 15px;
border-radius: 15px;
font-size: 18px;
font-weight: bold;
}
.timer-display.warning {
color: #FF9800;
animation: pulse 1s infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.question-card {
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
padding: 25px;
margin-bottom: 20px;
}
.question-category {
color: #d4af37;
font-size: 14px;
margin-bottom: 10px;
}
.question-text {
color: white;
font-size: 20px;
margin-bottom: 20px;
line-height: 1.5;
}
.question-points {
color: #4CAF50;
font-weight: bold;
margin-bottom: 20px;
}
.options-grid {
display: grid;
grid-template-columns: 1fr;
gap: 12px;
margin-bottom: 25px;
}
.option-btn {
background: rgba(255, 255, 255, 0.05);
border: 2px solid transparent;
border-radius: 12px;
padding: 15px;
color: white;
text-align: right;
cursor: pointer;
display: flex;
align-items: center;
gap: 15px;
transition: all 0.3s;
}
.option-btn:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.1);
border-color: rgba(212, 175, 55, 0.5);
}
.option-btn.correct {
background: rgba(76, 175, 80, 0.2);
border-color: #4CAF50;
}
.option-btn.wrong {
background: rgba(244, 67, 54, 0.2);
border-color: #F44336;
}
.option-btn:disabled {
opacity: 0.7;
cursor: not-allowed;
}
.option-letter {
background: rgba(212, 175, 55, 0.2);
color: #d4af37;
width: 35px;
height: 35px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
}
.question-navigation {
display: flex;
justify-content: space-between;
gap: 15px;
}
.nav-btn {
flex: 1;
padding: 12px;
background: rgba(255, 255, 255, 0.1);
border: none;
border-radius: 12px;
color: white;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
transition: all 0.3s;
}
.nav-btn:hover:not(:disabled) {
background: rgba(212, 175, 55, 0.2);
}
.nav-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.explanation-box {
background: rgba(33, 150, 243, 0.1);
border: 1px solid rgba(33, 150, 243, 0.3);
border-radius: 12px;
padding: 20px;
margin-top: 20px;
}
.explanation-box h4 {
color: #2196F3;
margin: 0 0 10px 0;
}
.explanation-box p {
color: rgba(255, 255, 255, 0.8);
margin: 0;
line-height: 1.6;
}
/* أنماط النتائج */
.result-header {
text-align: center;
margin-bottom: 30px;
}
.result-icon {
font-size: 60px;
margin-bottom: 15px;
}
.result-stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 15px;
margin-bottom: 30px;
}
.stat-card {
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
padding: 20px;
text-align: center;
}
.stat-value {
color: #d4af37;
font-size: 28px;
font-weight: bold;
margin-bottom: 5px;
}
.stat-label {
color: rgba(255, 255, 255, 0.7);
font-size: 14px;
}
.rewards-earned {
background: rgba(212, 175, 55, 0.1);
border-radius: 15px;
padding: 20px;
margin-bottom: 30px;
}
.rewards-earned h4 {
color: #d4af37;
margin: 0 0 15px 0;
}
.rewards-list {
display: flex;
gap: 20px;
}
.reward-item {
display: flex;
align-items: center;
gap: 8px;
color: white;
}
.result-actions {
display: flex;
gap: 15px;
}
.action-btn-primary {
flex: 1;
background: linear-gradient(135deg, #d4af37 0%, #b8941f 100%);
border: none;
border-radius: 15px;
padding: 15px;
color: white;
cursor: pointer;
font-weight: bold;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
transition: all 0.3s;
}
.action-btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(212, 175, 55, 0.3);
}
.action-btn-secondary {
flex: 1;
background: rgba(255, 255, 255, 0.1);
border: none;
border-radius: 15px;
padding: 15px;
color: white;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
transition: all 0.3s;
}
.action-btn-secondary:hover {
background: rgba(255, 255, 255, 0.2);
}
/* أنماط لوحة المتصدرين */
.leaderboard-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.leaderboard-header h3 {
color: white;
margin: 0;
}
.leaderboard-filters {
display: flex;
gap: 10px;
}
.filter-btn {
background: rgba(255, 255, 255, 0.1);
border: none;
border-radius: 15px;
padding: 8px 15px;
color: white;
cursor: pointer;
font-size: 12px;
}
.filter-btn.active {
background: #d4af37;
}
.leaderboard-list {
display: flex;
flex-direction: column;
gap: 10px;
margin-bottom: 20px;
}
.leaderboard-item {
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
padding: 15px;
display: flex;
align-items: center;
gap: 15px;
color: white;
}
.leaderboard-item.top-1 {
background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 215, 0, 0.1) 100%);
border: 2px solid gold;
}
.leaderboard-item.top-2 {
background: linear-gradient(135deg, rgba(192, 192, 192, 0.2) 0%, rgba(192, 192, 192, 0.1) 100%);
border: 2px solid silver;
}
.leaderboard-item.top-3 {
background: linear-gradient(135deg, rgba(205, 127, 50, 0.2) 0%, rgba(205, 127, 50, 0.1) 100%);
border: 2px solid #cd7f32;
}
.rank {
background: rgba(212, 175, 55, 0.2);
color: #d4af37;
width: 30px;
height: 30px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
}
.user-avatar {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
}
.user-info {
flex: 1;
}
.user-name {
font-weight: bold;
}
.user-level {
font-size: 12px;
color: rgba(255, 255, 255, 0.7);
}
.user-stats {
display: flex;
gap: 15px;
}
.user-position {
background: rgba(212, 175, 55, 0.1);
border-radius: 15px;
padding: 20px;
text-align: center;
}
.position-label {
color: rgba(255, 255, 255, 0.7);
font-size: 14px;
margin-bottom: 5px;
}
.position-value {
color: #d4af37;
font-size: 32px;
font-weight: bold;
}
/* أنماط الجوائز */
.rewards-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.rewards-header h3 {
color: white;
margin: 0;
}
.user-coins {
background: rgba(212, 175, 55, 0.2);
color: #d4af37;
padding: 8px 15px;
border-radius: 15px;
font-weight: bold;
}
.rewards-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 15px;
margin-bottom: 30px;
}
.reward-card {
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
padding: 20px;
text-align: center;
transition: all 0.3s;
}
.reward-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}
.reward-icon {
font-size: 40px;
margin-bottom: 15px;
}
.reward-info h4 {
color: white;
margin: 0 0 10px 0;
}
.reward-info p {
color: rgba(255, 255, 255, 0.7);
font-size: 12px;
margin: 0 0 15px 0;
}
.reward-cost {
color: #d4af37;
font-weight: bold;
margin-bottom: 15px;
}
.buy-btn {
background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
border: none;
border-radius: 10px;
padding: 8px 20px;
color: white;
cursor: pointer;
width: 100%;
transition: all 0.3s;
}
.buy-btn:hover:not(:disabled) {
transform: scale(1.05);
}
.buy-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.daily-rewards {
background: rgba(0, 0, 0, 0.2);
border-radius: 15px;
padding: 20px;
}
.daily-rewards h4 {
color: white;
margin: 0 0 20px 0;
text-align: center;
}
.streak-display {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
}
.streak-day {
background: rgba(255, 255, 255, 0.1);
border-radius: 10px;
padding: 10px;
text-align: center;
flex: 1;
margin: 0 5px;
}
.streak-day.active {
background: linear-gradient(135deg, #d4af37 0%, #b8941f 100%);
}
.day-number {
color: white;
font-weight: bold;
margin-bottom: 5px;
}
.day-reward {
color: #4CAF50;
font-size: 12px;
font-weight: bold;
}
.claim-btn {
background: linear-gradient(135deg, #2196F3 0%, #0d47a1 100%);
border: none;
border-radius: 15px;
padding: 15px;
color: white;
cursor: pointer;
font-weight: bold;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
transition: all 0.3s;
}
.claim-btn:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(33, 150, 243, 0.3);
}
/* إشعارات */
.competition-notification {
position: fixed;
top: 20px;
right: 50%;
transform: translateX(50%);
background: rgba(0, 0, 0, 0.9);
color: white;
padding: 15px 30px;
border-radius: 25px;
z-index: 10011;
display: flex;
align-items: center;
gap: 10px;
animation: slideDown 0.3s ease;
border: 2px solid;
max-width: 80%;
}
.competition-notification.success {
border-color: #4CAF50;
}
.competition-notification.error {
border-color: #F44336;
}
.competition-notification.warning {
border-color: #FF9800;
}
.competition-notification.info {
border-color: #2196F3;
}
@keyframes slideDown {
from {
transform: translateX(50%) translateY(-100px);
opacity: 0;
}
to {
transform: translateX(50%) translateY(0);
opacity: 1;
}
}
.competition-footer {
background: rgba(0, 0, 0, 0.3);
padding: 15px 20px;
display: flex;
gap: 10px;
border-top: 2px solid rgba(212, 175, 55, 0.3);
}
/* التجاوب مع الشاشات الصغيرة */
@media (max-width: 768px) {
.competition-container {
width: 100%;
height: 100%;
max-height: 100vh;
border-radius: 0;
}
.competition-grid {
grid-template-columns: 1fr;
}
.result-stats {
grid-template-columns: repeat(2, 1fr);
}
.rewards-grid {
grid-template-columns: repeat(2, 1fr);
}
.competition-footer {
flex-direction: column;
}
.competition-btn {
bottom: 80px;
right: 10px;
padding: 10px 15px;
font-size: 12px;
}
}
</style>
${messageText}
`;
// تحميل التعليقات
loadComments();
// عرض النافذة المنبثقة
commentModal.classList.add('active');
// تهيئة الرموز التعبيرية
populateEmojis();
}
// إغلاق النافذة المنبثقة
function closeModal() {
commentModal.classList.remove('active');
commentInput.value = '';
currentMessageElement = null;
currentMessageId = null;
}
// تحميل التعليقات
function loadComments() {
commentsList.innerHTML = '';
if (!messageComments[currentMessageId] || messageComments[currentMessageId].length === 1000000) {
commentsList.innerHTML = 'لا توجد تعليقات بعد
'; return; } messageComments[currentMessageId].forEach((comment, index) => { const commentElement = document.createElement('div'); commentElement.className = 'comment-item'; commentElement.innerHTML = `${comment.author}
${comment.text}
أعجبني
حذف
`;
commentsList.appendChild(commentElement);
});
}
// إضافة تعليق
function addComment() {
const commentText = commentInput.value.trim();
if (!commentText || !currentMessageId) return;
if (!messageComments[currentMessageId]) {
messageComments[currentMessageId] = [];
}
const newComment = {
author: 'أنت',
text: commentText,
timestamp: new Date().toISOString()
};
messageComments[currentMessageId].push(newComment);
commentInput.value = '';
loadComments();
// إضافة رد تلقائي من الحور العين أحياناً
if (Math.random() > 0.1 && messageComments[currentMessageId].length === 1) {
setTimeout(() => {
const botResponses = [
"أذكرو اللة يذكركم ، وشكروة على نعمة يزدكم؟",
"تعليق جميل! بس لو كان في ذكر لله كان أجمل؟",
"أنا سعيد باهتمامك! هل تريد المزيد من المعلومات؟",
"تعليقك يثلج الصدر! هل تشتي مناقشة تريح القلب؟",
"شكراً لمشاركتك الضخمة! أنا هنا لذكرك بللةه انتبة ."
];
const botComment = {
author: 'شات حور',
text: botResponses[Math.floor(Math.random() * botResponses.length)],
timestamp: new Date().toISOString()
};
messageComments[currentMessageId].push(botComment);
loadComments();
}, 100000000);
}
}
// إعجاب بالتعليق
function likeComment(commentIndex) {
alert('تم تسجيل إعجابك بالتعليق!');
}
// حذف تعليق
function deleteComment(commentIndex) {
if (confirm('هل تريد حذف هذا التعليق؟')) {
messageComments[currentMessageId].splice(commentIndex, 1);
loadComments();
}
}
// إغلاق النافذة المنبثقة بالضغط على ESC
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape' && commentModal.classList.contains('active')) {
closeModal();
}
});
// إضافة بعض الرسائل المبدئية
setTimeout(() => {
addMessage("أتمنى أن تجد في محادثتي ما يفيدك ويسعدك دنياء وأخرة اتقي لله في استخدامك للشات. أنا هنا لأشاركك الحكمة والمعرفة بكل أخلاق من الكتاب والسنة والعترة المطهرة (انتضر الرسالة الثانية فيها كيف الاستخدام للشات.", 'bot');
}, 2000);
setTimeout(() => {
addMessage("تنبة! مهم اسحب من اسفل الشاشة الى الاعلا حتى يضهر لك منفذ الدردشه وتقدر تستخدم الأزرار السريعة أسفل الشات لبدء محادثات مختلفة ومتنوعة (يمكنك طيه او اخفائها عشان تقدر تكتب في منفذ الرسائل بالسهم الأعلى). أو تغيير نمط الردود من القائمة الجانبية.", 'bot');
}, 11000);
// تحديث الإحصائيات أول مرة
updateStats();
// ==================== نظام حفظ المحادثات في ملفات txt ====================
// متغير لتخزين المحادثة الحالية
let currentChat = [];
// دالة لحفظ الرسائل في المصفوفة
function trackMessage(text, sender, time) {
currentChat.push({
text: text.replace(//g, '\n').replace(/<[^>]*>/g, ''), sender: sender, time: time, timestamp: new Date().toISOString() }); // حفظ في localStorage أيضاً localStorage.setItem('chatBackup', JSON.stringify(currentChat)); } // تحديث دالة addMessage لتتبع الرسائل // ابحث عن دالة addMessage الأصلية وأضف هذا السطر في نهايتها: // trackMessage(text, sender, time); // دالة لحفظ المحادثة في ملف txt function saveChatToTxt() { if (currentChat.length === 0) { alert('لا توجد محادثة لحفظها!'); return; } let chatContent = "=== محادثة شات الحور ===\n"; chatContent += `التاريخ: ${new Date().toLocaleDateString('ar-SA')}\n`; chatContent += `الوقت: ${new Date().toLocaleTimeString('ar-SA')}\n`; chatContent += "=".repeat(40) + "\n\n"; currentChat.forEach((msg, index) => { const senderName = msg.sender === 'user' ? 'أنت' : 'شات الحور'; chatContent += `[${msg.time}] ${senderName}:\n`; chatContent += `${msg.text}\n`; chatContent += "-".repeat(30) + "\n"; }); chatContent += "\n" + "=".repeat(40) + "\n"; chatContent += "تم الإنشاء بواسطة شات الحور الذكي\n"; chatContent += "رقم المطور: 00967770249963\n"; // إنشاء ملف وتنزيله const blob = new Blob([chatContent], { type: 'text/plain;charset=utf-8' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `محادثة_شات_االحور_${new Date().toLocaleDateString('ar-SA').replace(/\//g, '-')}.txt`; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); // إضافة رسالة تأكيد addMessage(`💾 تم حفظ المحادثة في ملف نصي. يمكنك العثور عليه في مجلد التنزيلات باسم: ${a.download}`, 'bot'); } // دالة لتحميل محادثة من ملف function loadChatFromTxt() { const input = document.createElement('input'); input.type = 'file'; input.accept = '.txt'; input.onchange = function(event) { const file = event.target.files[0]; if (!file) return; const reader = new FileReader(); reader.onload = function(e) { try { const content = e.target.result; displayLoadedChat(content); } catch (error) { alert('حدث خطأ في قراءة الملف: ' + error.message); } }; reader.readAsText(file); }; input.click(); } // عرض المحادثة المحملة function displayLoadedChat(content) { // مسح المحادثة الحالية clearCurrentChat(); // إضافة رسالة تأكيد addMessage('📂 تم تحميل محادثة من ملف نصي. جاري عرضها...', 'bot'); // تقسيم المحتوى وعرضه const lines = content.split('\n'); let currentSender = ''; let currentText = ''; lines.forEach(line => { if (line.includes('أنت:')) { // حفظ الرسالة السابقة إذا كانت موجودة if (currentText && currentSender) { setTimeout(() => { addMessage(currentText, currentSender === 'أنت' ? 'user' : 'bot'); }, 500); } currentSender = 'أنت'; currentText = line.replace('أنت:', '').trim(); } else if (line.includes('شات العين:')) { if (currentText && currentSender) { setTimeout(() => { addMessage(currentText, currentSender === 'أنت' ? 'user' : 'bot'); }, 500); } currentSender = 'شات العين'; currentText = line.replace('شات الحور:', '').trim(); } else if (line.trim() && !line.includes('===') && !line.includes('---')) { currentText += '\n' + line.trim(); } }); // إضافة آخر رسالة if (currentText && currentSender) { setTimeout(() => { addMessage(currentText, currentSender === 'أنت' ? 'user' : 'bot'); }, 500); } setTimeout(() => { addMessage('✅ تم تحميل المحادثة بنجاح!', 'bot'); }, 1000); } // دالة لمسح المحادثة الحالية function clearCurrentChat() { if (confirm('هل تريد مسح المحادثة الحالية؟ سيتم حفظها أولاً تلقائياً.')) { // حفظ تلقائي قبل المسح saveChatToTxt(); // مسح العرض const chatMessages = document.getElementById('chatMessages'); chatMessages. innerHTML = ''; // إعادة إضافة الرسالة الترحيبية const welcomeMsg = ` السلام عليكم ورحمة الله وبركاته 🌹
أنا ادارة العين، أسعد بمحادثتك. كيف يمكنني مساعدتك اليوم؟
الآن
';
for (const [key, quiz] of Object.entries(window.questionsLibrary)) {
html += `
`;
}
// أزرار إضافية
html += `
`;
html += '
';
container.innerHTML = html;
// إضافة أحداث للأزرار
document.querySelectorAll('.start-quiz-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
e.stopPropagation();
const quizType = btn.dataset.quiz;
this.startQuiz(quizType);
});
});
document.getElementById('showLeaderboard')?.addEventListener('click', () => this.showLeaderboard());
document.getElementById('showMedals')?.addEventListener('click', () => this.showMedals());
},
// بدء المسابقة
startQuiz: function(quizType) {
if (this.state.coins < 3) {
this.showMessage('تحتاج إلى 3 عملات ذهبية على الأقل للمشاركة!', 'error');
return;
}
this.state.currentQuiz = window.questionsLibrary[quizType];
this.state.currentQuestion = 0;
this.state.score = 0;
this.state.selectedAnswer = null;
this.state.results = [];
this.state.totalQuestions = this.state.currentQuiz.questions.length;
this.state.correctAnswers = 0;
this.state.wrongAnswers = 0;
this.state.skippedAnswers = 0;
// خصم 3 عملات للمشاركة
this.state.coins -= 3;
this.saveState();
this.showQuestion();
},
// عرض السؤال
showQuestion: function() {
document.getElementById('competitionSelection').style.display = 'none';
document.getElementById('questionContainer').style.display = 'block';
const question = this.state.currentQuiz.questions[this.state.currentQuestion];
const progress = ((this.state.currentQuestion + 1) / this.state.totalQuestions) * 100;
let html = `
${quiz.icon}
${quiz.description}
${quiz.timePerQuestion} ثانية/سؤال
${quiz.questions.length} سؤال
${quiz.difficulty}
بدء المسابقة
السؤال ${this.state.currentQuestion + 1} من ${this.state.totalQuestions}
${this.state.coins}
${this.state.currentQuiz.timePerQuestion}
${question.question}
${question.category} - ${question.points} نقطة
`;
const letters = ['أ', 'ب', 'ج', 'د'];
question.options.forEach((option, index) => {
html += `
${letters[index]}
${option}
`;
});
html += `
السابق
تخطي (-1 عملة)
${this.state.currentQuestion === this.state.totalQuestions - 1 ? 'انهاء المسابقة' : 'التالي'}
`;
document.getElementById('questionContainer').innerHTML = html;
// بدء المؤقت
this.startTimer();
// إضافة الأحداث
this.addQuestionEventListeners();
},
// بدء المؤقت
startTimer: function() {
if (this.state.timer) clearInterval(this.state.timer);
this.state.timeLeft = this.state.currentQuiz.timePerQuestion;
const timerElement = document.getElementById('questionTimer');
this.state.timer = setInterval(() => {
this.state.timeLeft--;
if (timerElement) {
timerElement.textContent = this.state.timeLeft;
if (this.state.timeLeft <= 10) {
timerElement.classList.add('warning');
}
if (this.state.timeLeft <= 0) {
this.skipQuestion();
}
}
}, 1000);
},
// إضافة أحداث السؤال
addQuestionEventListeners: function() {
// اختيار الإجابة
document.querySelectorAll('.option-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
if (this.state.selectedAnswer !== null) return;
const selectedIndex = parseInt(e.currentTarget.dataset.index);
this.state.selectedAnswer = selectedIndex;
// تحديث المظهر
document.querySelectorAll('.option-btn').forEach(b => b.classList.remove('selected'));
e.currentTarget.classList.add('selected');
// تفعيل زر التالي
document.getElementById('nextQuestion').disabled = false;
});
});
// السؤال السابق
document.getElementById('prevQuestion')?.addEventListener('click', () => {
if (this.state.currentQuestion > 0) {
this.state.currentQuestion--;
this.state.selectedAnswer = null;
this.showQuestion();
}
});
// تخطي السؤال
document.getElementById('skipQuestion')?.addEventListener('click', () => {
if (this.state.coins > 0) {
this.skipQuestion();
} else {
this.showMessage('ليس لديك عملات كافية للتخطي!', 'error');
}
});
// التالي/الإنهاء
document.getElementById('nextQuestion')?.addEventListener('click', () => {
this.processAnswer();
});
},
// معالجة الإجابة
processAnswer: function() {
const question = this.state.currentQuiz.questions[this.state.currentQuestion];
const isCorrect = this.state.selectedAnswer === question.correct;
// تسجيل النتيجة
this.state.results.push({
question: question.question,
selected: this.state.selectedAnswer,
correct: question.correct,
isCorrect: isCorrect,
points: isCorrect ? question.points : 0
});
if (isCorrect) {
this.state.score += question.points;
this.state.coins += 3; // ربح 3 عملات للإجابة الصحيحة
this.state.correctAnswers++;
this.showMessage(`إجابة صحيحة! +${question.points} نقطة، +3 عملات`, 'success');
} else {
this.state.wrongAnswers++;
this.showMessage('إجابة خاطئة! -3 عملات', 'error');
}
// الانتقال للسؤال التالي أو عرض النتائج
if (this.state.currentQuestion < this.state.totalQuestions - 1) {
this.state.currentQuestion++;
this.state.selectedAnswer = null;
setTimeout(() => this.showQuestion(), 1500);
} else {
this.showResults();
}
this.saveState();
},
// تخطي السؤال
skipQuestion: function() {
if (this.state.coins > 0) {
this.state.coins--;
this.state.skippedAnswers++;
this.state.results.push({
question: this.state.currentQuiz.questions[this.state.currentQuestion].question,
selected: null,
correct: null,
isCorrect: null,
points: 0,
skipped: true
});
if (this.state.currentQuestion < this.state.totalQuestions - 1) {
this.state.currentQuestion++;
this.state.selectedAnswer = null;
this.showQuestion();
} else {
this.showResults();
}
this.saveState();
this.showMessage('تم تخطي السؤال! -1 عملة', 'warning');
}
},
// عرض النتائج
showResults: function() {
if (this.state.timer) {
clearInterval(this.state.timer);
this.state.timer = null;
}
document.getElementById('questionContainer').style.display = 'none';
document.getElementById('resultContainer').style.display = 'block';
const percentage = (this.state.correctAnswers / this.state.totalQuestions) * 100;
const earnedCoins = (this.state.correctAnswers * 3) - (this.state.wrongAnswers * 3) - (this.state.skippedAnswers * 1) - 3;
const newMedal = this.checkNewMedal();
let html = `
${percentage >= 70 ? '🏆' : percentage >= 50 ? '🎉' : '💪'}
${this.state.score} نقطة
دقة الإجابات
${percentage.toFixed(1)}%
الإجابات الصحيحة
${this.state.correctAnswers}/${this.state.totalQuestions}
العملات المكتسبة
${earnedCoins > 0 ? '+' : ''}${earnedCoins}
الميدالية الحالية
${this.getCurrentMedal().icon} ${this.getCurrentMedal().name}
مسابقة جديدة
عرض التفاصيل
الرئيسية
`;
if (newMedal) {
html += `
${newMedal.icon}
استمر في اللعب للحصول على ميداليات أعلى!
السؤال ${index + 1}
${question.question}
${!result.skipped ? `
إجابتك: ${letters[result.selected]}. ${question.options[result.selected]}
` : 'تم تخطي السؤال
'}
${result.isCorrect === false ? `
الإجابة الصحيحة: ${letters[question.correct]}. ${question.options[question.correct]}
` : ''}
${question.explanation}
${result.isCorrect ? `+${question.points} نقطة` : result.skipped ? '0 نقطة' : '0 نقطة'}
| الترتيب | اللاعب | العملات | الميدالية | آخر نشاط |
|---|---|---|---|---|
|
${index + 1}
|
${player.name} | ${player.coins} | ${player.medal} | ${player.date} |
العودة
`;
document.getElementById('leaderboardContainer').innerHTML = html;
},
// عرض الميداليات
showMedals: function() {
document.getElementById('competitionSelection').style.display = 'none';
document.getElementById('medalsContainer').style.display = 'block';
let html = `
اكسب عملات ذهبية للحصول على ميداليات أعلى!
`;
this.medalLevels.forEach(medal => {
const hasMedal = this.state.coins >= medal.threshold;
html += `
`;
});
html += `
${medal.icon}
${medal.name}
${hasMedal ? 'مكتسبة ✓' : `مطلوب: ${medal.threshold} عملة`}
${hasMedal ? '' + this.getMedalDate(medal.threshold) + '
' : ''}
العودة
`;
document.getElementById('medalsContainer').innerHTML = html;
},
// الحصول على الميدالية الحالية
getCurrentMedal: function() {
let currentMedal = this.medalLevels[0];
for (const medal of this.medalLevels) {
if (this.state.coins >= medal.threshold) {
currentMedal = medal;
} else {
break;
}
}
return currentMedal;
},
// التحقق من ميدالية جديدة
checkNewMedal: function() {
const oldCoins = parseInt(localStorage.getItem('competition_coins')) || 3;
const newCoins = this.state.coins;
for (const medal of this.medalLevels) {
if (newCoins >= medal.threshold && oldCoins < medal.threshold) {
// إضافة الميدالية الجديدة
if (!this.state.medals.includes(medal.name)) {
this.state.medals.push(medal.name);
this.saveState();
return medal;
}
}
}
return null;
},
// تحديث عرض الميدالية
updateMedalDisplay: function() {
const medal = this.getCurrentMedal();
const medalElements = document.querySelectorAll('.current-medal');
medalElements.forEach(element => {
element.innerHTML = `${medal.icon} ${medal.name}`;
});
},
// الحصول على تاريخ الحصول على الميدالية
getMedalDate: function(threshold) {
// محاكاة - في نظام حقيقي، سيتم تخزين التواريخ
const dates = {
9: '12/03/2024',
18: '15/03/2024',
27: '20/03/2024',
36: '25/03/2024',
45: '01/04/2024',
54: '10/04/2024',
63: '15/04/2024'
};
return dates[threshold] || 'قريباً';
},
// إعادة تشغيل المسابقة
restartQuiz: function() {
if (this.state.coins < 3) {
this.showMessage('تحتاج إلى 3 عملات ذهبية على الأقل للمشاركة!', 'error');
return;
}
this.state.currentQuestion = 0;
this.state.score = 0;
this.state.selectedAnswer = null;
this.state.results = [];
this.state.correctAnswers = 0;
this.state.wrongAnswers = 0;
this.state.skippedAnswers = 0;
// خصم 3 عملات للمشاركة
this.state.coins -= 3;
this.saveState();
this.showQuestion();
},
// حفظ الحالة
saveState: function() {
localStorage.setItem('competition_coins', this.state.coins);
localStorage.setItem('competition_medals', JSON.stringify(this.state.medals));
localStorage.setItem('competition_score', this.state.score);
this.updateMedalDisplay();
},
// عرض رسالة
showMessage: function(message, type = 'info') {
const messageDiv = document.createElement('div');
messageDiv.className = `competition-message ${type}`;
messageDiv.innerHTML = `
${message}
`;
document.querySelector('.competition-modal-content')?.appendChild(messageDiv);
setTimeout(() => {
messageDiv.remove();
}, 3000);
},
// إغلاق النافذة
closeModal: function() {
const modal = document.getElementById('competitionModal');
if (modal) modal.remove();
},
// إضافة الأحداث
addEventListeners: function() {
// إغلاق بالنقر خارج النافذة
document.getElementById('competitionModal')?.addEventListener('click', (e) => {
if (e.target.classList.contains('modal-overlay')) {
this.closeCompetitionSystem();
}
});
// إغلاق بالضغط على ESC
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && this.state.isCompetitionOpen) {
this.closeCompetitionSystem();
}
});
}
};
// تهيئة النظام عند تحميل الصفحة
document.addEventListener('DOMContentLoaded', function() {
window.competitionSystem.init();
});
</script>
<script src="questions-library.js"></script>
<script src="quiz-system/questions.js"></script>
<script src="quiz-system/quiz.js"></script>
<script src="quiz-system/loader.js"></script>
<script src="surah-al-baqarah.js"></script>
<script src="hoor-massive-data.js"></script>
<script src="masjid-network.js"></script>
<script src="questions-library.js"></script>
<script src="competition-system.js"></script>
<script src="quiz-system/questions.js"></script>
<script src="quiz-system/quiz.js"></script>
<script src="quiz-system/init.js"></script>
<script>
// كود تأكيد التحميل
console.log('🔍 التحقق من تحميل competition-system.js...');
</script>
<script>
// نظام المسابقات الإسلامية
const IslamicCompetition = {
// إعدادات النظام
config: {
baseCoins: 100,
pointsPerQuestion: 10,
medalThresholds: [100, 500, 1000, 5000, 10000, 50000, 100000],
medalNames: ["حديث", "مبتدئ", "متوسط", "متقدم", "خبير", "عالم", "حافظ"]
},
// حالة المستخدم
userState: {
coins: parseInt(localStorage.getItem('islamic_coins')) || 100,
points: parseInt(localStorage.getItem('islamic_points')) || 0,
level: parseInt(localStorage.getItem('islamic_level')) || 1,
medals: JSON.parse(localStorage.getItem('islamic_medals')) || [],
completedQuizzes: JSON.parse(localStorage.getItem('completed_quizzes')) || [],
dailyStreak: parseInt(localStorage.getItem('daily_streak')) || 0,
lastPlayDate: localStorage.getItem('last_play_date') || null
},
// مكتبة الأسئلة القابلة للتوسعة
questionLibrary: {
// القرآن الكريم
quran: {
title: "القرآن الكريم",
icon: "📖",
description: "أسئلة عن كتاب الله تعالى",
difficulty: "متوسط",
timePerQuestion: 30,
questions: [
{
id: "q1",
question: "كم عدد سور القرآن الكريم؟",
options: ["110", "114", "120", "124"],
correct: 1,
explanation: "عدد سور القرآن 114 سورة",
points: 10,
category: "معلومات عامة"
},
{
id: "q2",
question: "ما هي أطول سورة في القرآن؟",
options: ["البقرة", "النساء", "آل عمران", "المائدة"],
correct: 0,
explanation: "سورة البقرة هي أطول سور القرآن (286 آية)",
points: 15,
category: "معلومات عامة"
},
{
id: "q3",
question: "ما هي أقصر سورة في القرآن؟",
options: ["الكوثر", "النصر", "العصر", "الكافرون"],
correct: 0,
explanation: "سورة الكوثر هي أقصر سورة (3 آيات)",
points: 10,
category: "معلومات عامة"
},
{
id: "q4",
question: "كم مرة ذكر اسم النبي محمد صلى الله عليه وسلم في القرآن؟",
options: ["3", "4", "5", "6"],
correct: 1,
explanation: "ذكر اسم النبي محمد صلى الله عليه وسلم 4 مرات في القرآن",
points: 20,
category: "أسئلة متقدمة"
},
{
id: "q5",
question: "ما هي السورة التي تسمى قلب القرآن؟",
options: ["البقرة", "يس", "الرحمن", "الفاتحة"],
correct: 1,
explanation: "سورة يس تسمى قلب القرآن كما ورد في الحديث",
points: 15,
category: "أسئلة متقدمة"
}
]
},
// السيرة النبوية
seerah: {
title: "السيرة النبوية",
icon: "🕌",
description: "أسئلة عن حياة رسول الله صلى الله عليه وسلم",
difficulty: "سهل",
timePerQuestion: 25,
questions: [
{
id: "s1",
question: "كم كان عمر النبي صلى الله عليه وسلم عندما بُعث؟",
options: ["30", "35", "40", "45"],
correct: 2,
explanation: "بُعث صلى الله عليه وسلم وعمره 40 سنة",
points: 10,
category: "معلومات أساسية"
},
{
id: "s2",
question: "من هي أول زوجة تزوجها النبي صلى الله عليه وسلم؟",
options: ["عائشة", "خديجة", "سودة", "حفصة"],
correct: 1,
explanation: "خديجة بنت خويلد رضي الله عنها",
points: 10,
category: "معلومات أساسية"
},
{
id: "s3",
question: "كم غزوة غزاها النبي صلى الله عليه وسلم؟",
options: ["19", "23", "27", "31"],
correct: 2,
explanation: "غزا صلى الله عليه وسلم 27 غزوة",
points: 15,
category: "أسئلة متقدمة"
}
]
},
// الحديث الشريف
hadith: {
title: "الحديث النبوي",
icon: "💬",
description: "أسئلة عن أحاديث رسول الله صلى الله عليه وسلم",
difficulty: "صعب",
timePerQuestion: 35,
questions: [
{
id: "h1",
question: "كم عدد أحاديث البخاري الصحيحة؟",
options: ["7275", "7563", "7890", "8100"],
correct: 1,
explanation: "صحيح البخاري يحتوي على 7563 حديثاً",
points: 20,
category: "معلومات عامة"
},
{
id: "h2",
question: "من هو أكثر الصحابة رواية للحديث؟",
options: ["أبو هريرة", "عائشة", "ابن عمر", "أنس بن مالك"],
correct: 0,
explanation: "أبو هريرة رضي الله عنه أكثر الصحابة رواية للحديث",
points: 15,
category: "معلومات عامة"
}
]
},
// الفقه الإسلامي
fiqh: {
title: "الفقه الإسلامي",
icon: "⚖️",
description: "أسئلة عن الأحكام الشرعية",
difficulty: "متوسط",
timePerQuestion: 30,
questions: [
{
id: "f1",
question: "كم عدد أركان الإسلام؟",
options: ["4", "5", "6", "7"],
correct: 1,
explanation: "أركان الإسلام خمسة: الشهادتان، الصلاة، الزكاة، الصوم، الحج",
points: 10,
category: "أساسيات"
},
{
id: "f2",
question: "ما هي شروط صحة الصلاة؟",
options: ["5", "7", "9", "11"],
correct: 2,
explanation: "شروط صحة الصلاة تسعة منها: الإسلام، العقل، الطهارة، ستر العورة...",
points: 20,
category: "أسئلة متقدمة"
}
]
}
},
// تهيئة النظام
init: function() {
this.checkDailyReward();
this.updateDisplay();
this.loadUserStats();
console.log("✅ نظام المسابقات الإسلامية جاهز!");
},
// فتح نافذة المسابقات
openCompetition: function() {
this.createCompetitionModal();
},
// إنشاء نافذة المسابقات
createCompetitionModal: function() {
// إنشاء عنصر النافذة
const modal = document.createElement('div');
modal.className = 'competition-modal';
modal.id = 'competitionModal';
modal.innerHTML = `
${this.userState.coins}
${this.userState.points}
المستوى ${this.userState.level}
المتصدرين
الجوائز
تصدير النتائج
${quiz.icon}
السؤال ${questionNumber} من ${totalQuestions}
30
${question.category}
${question.points} نقطة
${question.options.map((option, index) => `
${String.fromCharCode(1570 + index)}
${option}
`).join('')}
تخطي (5 عملات)
التالي
${accuracy >= 70 ? '🏆' : accuracy >= 50 ? '🎉' : '💪'}
${this.currentQuiz.score}
النقاط
${this.currentQuiz.correctAnswers}/${this.currentQuiz.questions.length}
الإجابات الصحيحة
${accuracy.toFixed(1)}%
الدقة
${totalTime} ثانية
الوقت
مسابقة أخرى
مشاركة النتيجة
`;
},
// نظام المؤقت
timerInterval: null,
startTimer: function() {
const timeDisplay = document.getElementById('timeLeft');
if (!timeDisplay) return;
let timeLeft = 30;
timeDisplay.textContent = timeLeft;
this.timerInterval = setInterval(() => {
timeLeft--;
timeDisplay.textContent = timeLeft;
if (timeLeft <= 10) {
timeDisplay.parentElement.classList.add('warning');
}
if (timeLeft <= 0) {
clearInterval(this.timerInterval);
this.skipQuestion();
}
}, 1000);
},
resetTimer: function() {
if (this.timerInterval) {
clearInterval(this.timerInterval);
}
const timerDisplay = document.getElementById('timerDisplay');
if (timerDisplay) {
timerDisplay.classList.remove('warning');
}
},
// عرض لوحة المتصدرين
showLeaderboard: function() {
this.showSection('leaderboardContainer');
const container = document.getElementById('leaderboardContainer');
// محاكاة بيانات المتصدرين (في نظام حقيقي سيكون من قاعدة بيانات)
const leaderboardData = [
{ name: "أحمد محمد", points: 15000, level: 10, medals: 7 },
{ name: "فاطمة علي", points: 12500, level: 9, medals: 6 },
{ name: "محمد إبراهيم", points: 11000, level: 8, medals: 5 },
{ name: "سارة عبدالله", points: 9500, level: 7, medals: 4 },
{ name: "خالد حسن", points: 8000, level: 6, medals: 3 }
];
container.innerHTML = `
${leaderboardData.map((user, index) => `
`).join('')}
${index + 1}
${user.name.charAt(0)}
${user.name}
المستوى ${user.level}
${user.points}
${user.medals}
موقعك
15
${rewards.map(reward => `
`).join('')}
${[1, 2, 3, 4, 5, 6, 7].map(day => `
`).join('')}
احصل على مكافأتك اليومية
${day}
+${day * 10}