| <!DOCTYPE html> |
| <html lang="ar" dir="rtl"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>Gemini Emulator - Stable GPT-4</title> |
| <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> |
| <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;700&display=swap" rel="stylesheet"> |
| <style> |
| body { font-family: 'Cairo', sans-serif; background-color: #1e1e2e; color: #cdd6f4; height: 100vh; display: flex; flex-direction: column; margin: 0; } |
| .chat-container { max-width: 800px; width: 100%; margin: auto; background: #252538; border-radius: 15px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); overflow: hidden; display: flex; flex-direction: column; height: 85vh; } |
| .chat-header { background: #11111b; padding: 15px; text-align: center; border-bottom: 1px solid #45475a; } |
| .chat-messages { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; } |
| .message { max-width: 75%; padding: 12px 16px; border-radius: 15px; margin-bottom: 5px; line-height: 1.6; white-space: pre-wrap; } |
| .message.user { background-color: #89b4fa; color: #11111b; align-self: flex-start; border-bottom-right-radius: 2px; } |
| .message.bot { background-color: #45475a; color: #cdd6f4; align-self: flex-end; border-bottom-left-radius: 2px; } |
| .chat-input-area { padding: 15px; background: #11111b; border-top: 1px solid #45475a; } |
| .input-group input { background: #313244; border: 1px solid #45475a; color: #cdd6f4; } |
| .input-group input:focus { background: #313244; color: #cdd6f4; box-shadow: none; border-color: #89b4fa; } |
| .btn-custom { background-color: #89b4fa; color: #11111b; font-weight: bold; } |
| .btn-custom:hover { background-color: #b4befe; } |
| ::-webkit-scrollbar { width: 6px; } |
| ::-webkit-scrollbar-track { background: #252538; } |
| ::-webkit-scrollbar-thumb { background: #45475a; border-radius: 10px; } |
| </style> |
| </head> |
| <body> |
|
|
| <div class="container d-flex flex-column justify-content-center align-items-center h-100"> |
| <div class="chat-container my-3"> |
| <div class="chat-header"> |
| <h4 class="m-0 text-info">Gemini Emulator</h4> |
| <small class="text-muted">بنية تحتية بـ Flask - مجاني وآمن 100% بدون CORS</small> |
| </div> |
| |
| <div class="chat-messages" id="chatMessages"> |
| <div class="message bot">مرحباً يا أنس! الآن الشات يعمل عبر سيرفرك الخاص، مجاني تماماً وبدون أي طلب دفع للمستخدمين. كيف أساعدك؟</div> |
| </div> |
|
|
| <div class="chat-input-area"> |
| <form id="chatForm" onsubmit="sendMessage(event)"> |
| <div class="input-group"> |
| <input type="text" id="userInput" class="form-control" placeholder="اكتب سؤالك هنا..." required autocomplete="off"> |
| <button class="btn btn-custom" type="submit" id="sendBtn">إرسال</button> |
| </div> |
| </form> |
| </div> |
| </div> |
| </div> |
|
|
| <script> |
| async function sendMessage(event) { |
| event.preventDefault(); |
| |
| const inputField = document.getElementById('userInput'); |
| const sendButton = document.getElementById('sendBtn'); |
| const chatMessages = document.getElementById('chatMessages'); |
| const userText = inputField.value.trim(); |
| |
| if (!userText) return; |
| |
| appendMessage(userText, 'user'); |
| inputField.value = ''; |
| |
| inputField.disabled = true; |
| sendButton.disabled = true; |
| |
| const loadingMessageDiv = appendMessage('جاري التفكير... ⏳', 'bot'); |
| |
| try { |
| |
| const response = await fetch('/chat', { |
| method: 'POST', |
| headers: { 'Content-Type': 'application/json' }, |
| body: JSON.stringify({ text: userText }) |
| }); |
| |
| const data = await response.json(); |
| |
| if (data.reply) { |
| loadingMessageDiv.innerText = data.reply; |
| } else { |
| loadingMessageDiv.innerText = "❌ خطأ في السيرفر الخارجي."; |
| } |
| |
| } catch (error) { |
| console.error(error); |
| loadingMessageDiv.innerText = "❌ تعذر الاتصال بالسيرفر الداخلي."; |
| loadingMessageDiv.style.color = "#f38ba8"; |
| } finally { |
| inputField.disabled = false; |
| sendButton.disabled = false; |
| inputField.focus(); |
| } |
| } |
| |
| function appendMessage(text, sender) { |
| const chatMessages = document.getElementById('chatMessages'); |
| const messageDiv = document.createElement('div'); |
| messageDiv.classList.add('message', sender); |
| messageDiv.innerText = text; |
| chatMessages.appendChild(messageDiv); |
| chatMessages.scrollTop = chatMessages.scrollHeight; |
| return messageDiv; |
| } |
| </script> |
|
|
| </body> |
| </html> |