Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +424 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: ai
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,424 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>QAdmar AI - Intelligent Chat Assistant</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
/* Custom scrollbar */
|
| 11 |
+
::-webkit-scrollbar {
|
| 12 |
+
width: 8px;
|
| 13 |
+
}
|
| 14 |
+
::-webkit-scrollbar-track {
|
| 15 |
+
background: #f1f1f1;
|
| 16 |
+
}
|
| 17 |
+
::-webkit-scrollbar-thumb {
|
| 18 |
+
background: #888;
|
| 19 |
+
border-radius: 4px;
|
| 20 |
+
}
|
| 21 |
+
::-webkit-scrollbar-thumb:hover {
|
| 22 |
+
background: #555;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/* Chat bubble animations */
|
| 26 |
+
@keyframes fadeIn {
|
| 27 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 28 |
+
to { opacity: 1; transform: translateY(0); }
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
.message-animation {
|
| 32 |
+
animation: fadeIn 0.3s ease-out;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/* Typing indicator */
|
| 36 |
+
.typing-indicator {
|
| 37 |
+
display: inline-flex;
|
| 38 |
+
align-items: center;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
.typing-dot {
|
| 42 |
+
width: 8px;
|
| 43 |
+
height: 8px;
|
| 44 |
+
background-color: #6b7280;
|
| 45 |
+
border-radius: 50%;
|
| 46 |
+
margin: 0 2px;
|
| 47 |
+
animation: typingAnimation 1.4s infinite ease-in-out;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.typing-dot:nth-child(1) {
|
| 51 |
+
animation-delay: 0s;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.typing-dot:nth-child(2) {
|
| 55 |
+
animation-delay: 0.2s;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.typing-dot:nth-child(3) {
|
| 59 |
+
animation-delay: 0.4s;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
@keyframes typingAnimation {
|
| 63 |
+
0%, 60%, 100% { transform: translateY(0); }
|
| 64 |
+
30% { transform: translateY(-5px); }
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/* Dark mode toggle */
|
| 68 |
+
.dark-mode-toggle {
|
| 69 |
+
transition: all 0.3s ease;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
.dark-mode-toggle:hover {
|
| 73 |
+
transform: rotate(30deg);
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/* RTL support */
|
| 77 |
+
.rtl {
|
| 78 |
+
direction: rtl;
|
| 79 |
+
text-align: right;
|
| 80 |
+
}
|
| 81 |
+
</style>
|
| 82 |
+
</head>
|
| 83 |
+
<body class="bg-gray-50 dark:bg-gray-900 transition-colors duration-300 min-h-screen flex flex-col">
|
| 84 |
+
<!-- Header -->
|
| 85 |
+
<header class="bg-indigo-600 dark:bg-indigo-800 text-white shadow-md">
|
| 86 |
+
<div class="container mx-auto px-4 py-3 flex justify-between items-center">
|
| 87 |
+
<div class="flex items-center space-x-3">
|
| 88 |
+
<div class="w-10 h-10 rounded-full bg-white dark:bg-gray-700 flex items-center justify-center">
|
| 89 |
+
<i class="fas fa-robot text-indigo-600 dark:text-indigo-300 text-xl"></i>
|
| 90 |
+
</div>
|
| 91 |
+
<h1 class="text-xl font-bold">QAdmar AI</h1>
|
| 92 |
+
</div>
|
| 93 |
+
<div class="flex items-center space-x-4">
|
| 94 |
+
<button id="languageToggle" class="px-3 py-1 bg-white dark:bg-gray-700 text-indigo-600 dark:text-indigo-300 rounded-full text-sm font-medium hover:bg-indigo-100 dark:hover:bg-gray-600 transition">
|
| 95 |
+
العربية
|
| 96 |
+
</button>
|
| 97 |
+
<button id="darkModeToggle" class="dark-mode-toggle text-white hover:text-indigo-200">
|
| 98 |
+
<i class="fas fa-moon text-xl"></i>
|
| 99 |
+
</button>
|
| 100 |
+
<button id="newChatBtn" class="px-3 py-1 bg-white dark:bg-gray-700 text-indigo-600 dark:text-indigo-300 rounded-full text-sm font-medium hover:bg-indigo-100 dark:hover:bg-gray-600 transition flex items-center">
|
| 101 |
+
<i class="fas fa-plus mr-1"></i> New Chat
|
| 102 |
+
</button>
|
| 103 |
+
</div>
|
| 104 |
+
</div>
|
| 105 |
+
</header>
|
| 106 |
+
|
| 107 |
+
<!-- Main Chat Area -->
|
| 108 |
+
<main class="flex-1 container mx-auto px-4 py-6 flex flex-col max-w-4xl">
|
| 109 |
+
<!-- Welcome message -->
|
| 110 |
+
<div id="welcomeMessage" class="text-center mb-8 message-animation">
|
| 111 |
+
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 inline-block max-w-2xl">
|
| 112 |
+
<h2 class="text-2xl font-bold text-indigo-600 dark:text-indigo-400 mb-2">Welcome to QAdmar AI</h2>
|
| 113 |
+
<p class="text-gray-600 dark:text-gray-300">I'm your intelligent assistant. Ask me anything, and I'll do my best to help you!</p>
|
| 114 |
+
<div class="mt-4 grid grid-cols-1 md:grid-cols-3 gap-3">
|
| 115 |
+
<button class="suggestion-btn px-4 py-2 bg-indigo-100 dark:bg-gray-700 text-indigo-700 dark:text-indigo-300 rounded-lg text-sm hover:bg-indigo-200 dark:hover:bg-gray-600 transition">
|
| 116 |
+
"Explain quantum computing"
|
| 117 |
+
</button>
|
| 118 |
+
<button class="suggestion-btn px-4 py-2 bg-indigo-100 dark:bg-gray-700 text-indigo-700 dark:text-indigo-300 rounded-lg text-sm hover:bg-indigo-200 dark:hover:bg-gray-600 transition">
|
| 119 |
+
"Write a poem about AI"
|
| 120 |
+
</button>
|
| 121 |
+
<button class="suggestion-btn px-4 py-2 bg-indigo-100 dark:bg-gray-700 text-indigo-700 dark:text-indigo-300 rounded-lg text-sm hover:bg-indigo-200 dark:hover:bg-gray-600 transition">
|
| 122 |
+
"How to learn JavaScript?"
|
| 123 |
+
</button>
|
| 124 |
+
</div>
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
|
| 128 |
+
<!-- Chat messages container -->
|
| 129 |
+
<div id="chatContainer" class="flex-1 overflow-y-auto mb-4 space-y-4 hidden">
|
| 130 |
+
<!-- Messages will be added here dynamically -->
|
| 131 |
+
</div>
|
| 132 |
+
|
| 133 |
+
<!-- Typing indicator (hidden by default) -->
|
| 134 |
+
<div id="typingIndicator" class="mb-4 hidden">
|
| 135 |
+
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-4 max-w-xs md:max-w-md">
|
| 136 |
+
<div class="typing-indicator">
|
| 137 |
+
<span class="typing-dot"></span>
|
| 138 |
+
<span class="typing-dot"></span>
|
| 139 |
+
<span class="typing-dot"></span>
|
| 140 |
+
</div>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
+
</main>
|
| 144 |
+
|
| 145 |
+
<!-- Input Area -->
|
| 146 |
+
<div class="bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 py-4 sticky bottom-0">
|
| 147 |
+
<div class="container mx-auto px-4 max-w-4xl">
|
| 148 |
+
<form id="chatForm" class="flex items-end space-x-2">
|
| 149 |
+
<div class="flex-1 relative">
|
| 150 |
+
<textarea
|
| 151 |
+
id="messageInput"
|
| 152 |
+
rows="1"
|
| 153 |
+
class="w-full px-4 py-3 pr-12 bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-200 rounded-lg border border-gray-300 dark:border-gray-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none"
|
| 154 |
+
placeholder="Type your message here..."
|
| 155 |
+
style="min-height: 50px; max-height: 150px;"></textarea>
|
| 156 |
+
<button
|
| 157 |
+
type="button"
|
| 158 |
+
id="sendButton"
|
| 159 |
+
class="absolute right-3 bottom-3 bg-indigo-600 text-white rounded-full p-2 hover:bg-indigo-700 transition disabled:opacity-50 disabled:cursor-not-allowed"
|
| 160 |
+
disabled>
|
| 161 |
+
<i class="fas fa-paper-plane"></i>
|
| 162 |
+
</button>
|
| 163 |
+
</div>
|
| 164 |
+
<button
|
| 165 |
+
type="button"
|
| 166 |
+
id="voiceButton"
|
| 167 |
+
class="bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-full p-3 hover:bg-gray-300 dark:hover:bg-gray-600 transition">
|
| 168 |
+
<i class="fas fa-microphone"></i>
|
| 169 |
+
</button>
|
| 170 |
+
</form>
|
| 171 |
+
<p class="text-xs text-gray-500 dark:text-gray-400 mt-2 text-center">
|
| 172 |
+
QAdmar AI may produce inaccurate information. Consider verifying important information.
|
| 173 |
+
</p>
|
| 174 |
+
</div>
|
| 175 |
+
</div>
|
| 176 |
+
|
| 177 |
+
<script>
|
| 178 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 179 |
+
// DOM Elements
|
| 180 |
+
const chatForm = document.getElementById('chatForm');
|
| 181 |
+
const messageInput = document.getElementById('messageInput');
|
| 182 |
+
const sendButton = document.getElementById('sendButton');
|
| 183 |
+
const voiceButton = document.getElementById('voiceButton');
|
| 184 |
+
const chatContainer = document.getElementById('chatContainer');
|
| 185 |
+
const welcomeMessage = document.getElementById('welcomeMessage');
|
| 186 |
+
const typingIndicator = document.getElementById('typingIndicator');
|
| 187 |
+
const darkModeToggle = document.getElementById('darkModeToggle');
|
| 188 |
+
const languageToggle = document.getElementById('languageToggle');
|
| 189 |
+
const newChatBtn = document.getElementById('newChatBtn');
|
| 190 |
+
const suggestionBtns = document.querySelectorAll('.suggestion-btn');
|
| 191 |
+
|
| 192 |
+
// State variables
|
| 193 |
+
let isRTL = false;
|
| 194 |
+
let isDarkMode = false;
|
| 195 |
+
let chatHistory = [];
|
| 196 |
+
|
| 197 |
+
// Initialize
|
| 198 |
+
checkDarkModePreference();
|
| 199 |
+
|
| 200 |
+
// Event Listeners
|
| 201 |
+
messageInput.addEventListener('input', handleInputChange);
|
| 202 |
+
chatForm.addEventListener('submit', handleSubmit);
|
| 203 |
+
sendButton.addEventListener('click', handleSubmit);
|
| 204 |
+
voiceButton.addEventListener('click', handleVoiceInput);
|
| 205 |
+
darkModeToggle.addEventListener('click', toggleDarkMode);
|
| 206 |
+
languageToggle.addEventListener('click', toggleLanguage);
|
| 207 |
+
newChatBtn.addEventListener('click', startNewChat);
|
| 208 |
+
suggestionBtns.forEach(btn => btn.addEventListener('click', handleSuggestionClick));
|
| 209 |
+
|
| 210 |
+
// Functions
|
| 211 |
+
function handleInputChange() {
|
| 212 |
+
// Auto-resize textarea
|
| 213 |
+
messageInput.style.height = 'auto';
|
| 214 |
+
messageInput.style.height = (messageInput.scrollHeight) + 'px';
|
| 215 |
+
|
| 216 |
+
// Enable/disable send button based on input
|
| 217 |
+
sendButton.disabled = messageInput.value.trim() === '';
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
function handleSubmit(e) {
|
| 221 |
+
e.preventDefault();
|
| 222 |
+
const message = messageInput.value.trim();
|
| 223 |
+
|
| 224 |
+
if (message) {
|
| 225 |
+
// Add user message to chat
|
| 226 |
+
addMessage(message, 'user');
|
| 227 |
+
|
| 228 |
+
// Clear input
|
| 229 |
+
messageInput.value = '';
|
| 230 |
+
messageInput.style.height = 'auto';
|
| 231 |
+
sendButton.disabled = true;
|
| 232 |
+
|
| 233 |
+
// Hide welcome message if it's the first message
|
| 234 |
+
if (welcomeMessage.style.display !== 'none') {
|
| 235 |
+
welcomeMessage.classList.add('hidden');
|
| 236 |
+
chatContainer.classList.remove('hidden');
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
// Show typing indicator
|
| 240 |
+
typingIndicator.classList.remove('hidden');
|
| 241 |
+
|
| 242 |
+
// Simulate AI response after a delay
|
| 243 |
+
setTimeout(() => {
|
| 244 |
+
typingIndicator.classList.add('hidden');
|
| 245 |
+
const aiResponse = generateAIResponse(message);
|
| 246 |
+
addMessage(aiResponse, 'ai');
|
| 247 |
+
|
| 248 |
+
// Scroll to bottom
|
| 249 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 250 |
+
}, 1000 + Math.random() * 2000); // Random delay between 1-3 seconds
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
function addMessage(content, sender) {
|
| 255 |
+
const messageDiv = document.createElement('div');
|
| 256 |
+
messageDiv.classList.add('message-animation');
|
| 257 |
+
|
| 258 |
+
if (sender === 'user') {
|
| 259 |
+
messageDiv.innerHTML = `
|
| 260 |
+
<div class="flex justify-end">
|
| 261 |
+
<div class="bg-indigo-600 text-white rounded-l-lg rounded-br-lg shadow-md p-4 max-w-xs md:max-w-md lg:max-w-lg">
|
| 262 |
+
<p class="${isRTL ? 'rtl' : ''}">${content}</p>
|
| 263 |
+
</div>
|
| 264 |
+
</div>
|
| 265 |
+
`;
|
| 266 |
+
} else {
|
| 267 |
+
messageDiv.innerHTML = `
|
| 268 |
+
<div class="flex justify-start">
|
| 269 |
+
<div class="bg-white dark:bg-gray-800 rounded-r-lg rounded-bl-lg shadow-md p-4 max-w-xs md:max-w-md lg:max-w-lg">
|
| 270 |
+
<p class="${isRTL ? 'rtl' : ''}">${content}</p>
|
| 271 |
+
<div class="mt-2 flex justify-end space-x-2 text-xs text-gray-500 dark:text-gray-400">
|
| 272 |
+
<button class="copy-btn hover:text-indigo-600 dark:hover:text-indigo-400" title="Copy">
|
| 273 |
+
<i class="fas fa-copy"></i>
|
| 274 |
+
</button>
|
| 275 |
+
<button class="regenerate-btn hover:text-indigo-600 dark:hover:text-indigo-400" title="Regenerate">
|
| 276 |
+
<i class="fas fa-sync-alt"></i>
|
| 277 |
+
</button>
|
| 278 |
+
</div>
|
| 279 |
+
</div>
|
| 280 |
+
</div>
|
| 281 |
+
`;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
chatContainer.appendChild(messageDiv);
|
| 285 |
+
|
| 286 |
+
// Add copy and regenerate functionality to new AI messages
|
| 287 |
+
if (sender === 'ai') {
|
| 288 |
+
const copyBtn = messageDiv.querySelector('.copy-btn');
|
| 289 |
+
const regenerateBtn = messageDiv.querySelector('.regenerate-btn');
|
| 290 |
+
|
| 291 |
+
copyBtn.addEventListener('click', () => {
|
| 292 |
+
navigator.clipboard.writeText(content);
|
| 293 |
+
copyBtn.innerHTML = '<i class="fas fa-check"></i>';
|
| 294 |
+
setTimeout(() => {
|
| 295 |
+
copyBtn.innerHTML = '<i class="fas fa-copy"></i>';
|
| 296 |
+
}, 2000);
|
| 297 |
+
});
|
| 298 |
+
|
| 299 |
+
regenerateBtn.addEventListener('click', () => {
|
| 300 |
+
messageDiv.remove();
|
| 301 |
+
typingIndicator.classList.remove('hidden');
|
| 302 |
+
|
| 303 |
+
setTimeout(() => {
|
| 304 |
+
typingIndicator.classList.add('hidden');
|
| 305 |
+
const newResponse = generateAIResponse(chatHistory[chatHistory.length - 1].content);
|
| 306 |
+
addMessage(newResponse, 'ai');
|
| 307 |
+
}, 1000 + Math.random() * 2000);
|
| 308 |
+
});
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
// Add to chat history
|
| 312 |
+
chatHistory.push({ content, sender });
|
| 313 |
+
|
| 314 |
+
// Scroll to bottom
|
| 315 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
function generateAIResponse(userMessage) {
|
| 319 |
+
// This is a mock response generator - in a real app, you'd call your AI API here
|
| 320 |
+
const responses = [
|
| 321 |
+
`I understand you're asking about "${userMessage}". While I don't have real-time data, I can provide general information on this topic.`,
|
| 322 |
+
`That's an interesting question about "${userMessage}". Here's what I know: [AI-generated response would appear here in a real implementation].`,
|
| 323 |
+
`Regarding "${userMessage}", my current knowledge suggests that [AI would generate a detailed response here]. Would you like me to elaborate?`,
|
| 324 |
+
`I've analyzed your query about "${userMessage}". Based on my training data, here's the most relevant information I can provide.`
|
| 325 |
+
];
|
| 326 |
+
|
| 327 |
+
const arabicResponses = [
|
| 328 |
+
`أنا أفهم أنك تسأل عن "${userMessage}". بينما لا أملك بيانات في الوقت الحقيقي، يمكنني تقديم معلومات عامة حول هذا الموضوع.`,
|
| 329 |
+
`هذا سؤال مثير للاهتمام حول "${userMessage}". إليك ما أعرفه: [سيظهر هنا رد تم إنشاؤه بواسطة الذكاء الاصطناعي في التنفيذ الحقيقي].`,
|
| 330 |
+
`بخصوص "${userMessage}"، تشير معرفتي الحالية إلى أن [سيولد الذكاء الاصطناعي ردًا مفصلاً هنا]. هل تريد مني أن أشرح أكثر؟`,
|
| 331 |
+
`لقد قمت بتحليل استفسارك حول "${userMessage}". بناءً على بياناتي التدريبية، إليك المعلومات الأكثر صلة التي يمكنني تقديمها.`
|
| 332 |
+
];
|
| 333 |
+
|
| 334 |
+
return isRTL
|
| 335 |
+
? arabicResponses[Math.floor(Math.random() * arabicResponses.length)]
|
| 336 |
+
: responses[Math.floor(Math.random() * responses.length)];
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
function handleVoiceInput() {
|
| 340 |
+
voiceButton.innerHTML = '<i class="fas fa-microphone-slash"></i>';
|
| 341 |
+
voiceButton.classList.remove('bg-gray-200', 'dark:bg-gray-700');
|
| 342 |
+
voiceButton.classList.add('bg-red-500', 'text-white');
|
| 343 |
+
|
| 344 |
+
// In a real app, this would use the Web Speech API
|
| 345 |
+
setTimeout(() => {
|
| 346 |
+
const spokenText = isRTL
|
| 347 |
+
? "هذه ميزة التعرف على الصوت. في التطبيق الحقيقي، سيقوم هذا بالاستماع إلى كلامك."
|
| 348 |
+
: "This is voice input. In a real app, this would listen to your speech.";
|
| 349 |
+
|
| 350 |
+
messageInput.value = spokenText;
|
| 351 |
+
handleInputChange();
|
| 352 |
+
|
| 353 |
+
voiceButton.innerHTML = '<i class="fas fa-microphone"></i>';
|
| 354 |
+
voiceButton.classList.remove('bg-red-500', 'text-white');
|
| 355 |
+
voiceButton.classList.add('bg-gray-200', 'dark:bg-gray-700');
|
| 356 |
+
}, 2000);
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
function toggleDarkMode() {
|
| 360 |
+
isDarkMode = !isDarkMode;
|
| 361 |
+
document.documentElement.classList.toggle('dark', isDarkMode);
|
| 362 |
+
localStorage.setItem('darkMode', isDarkMode);
|
| 363 |
+
|
| 364 |
+
darkModeToggle.innerHTML = isDarkMode
|
| 365 |
+
? '<i class="fas fa-sun text-xl"></i>'
|
| 366 |
+
: '<i class="fas fa-moon text-xl"></i>';
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
function checkDarkModePreference() {
|
| 370 |
+
if (localStorage.getItem('darkMode') === 'true' ||
|
| 371 |
+
(!localStorage.getItem('darkMode') && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
| 372 |
+
isDarkMode = true;
|
| 373 |
+
document.documentElement.classList.add('dark');
|
| 374 |
+
darkModeToggle.innerHTML = '<i class="fas fa-sun text-xl"></i>';
|
| 375 |
+
}
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
function toggleLanguage() {
|
| 379 |
+
isRTL = !isRTL;
|
| 380 |
+
languageToggle.textContent = isRTL ? 'English' : 'العربية';
|
| 381 |
+
|
| 382 |
+
// Update all existing messages
|
| 383 |
+
const messages = document.querySelectorAll('#chatContainer p');
|
| 384 |
+
messages.forEach(msg => {
|
| 385 |
+
msg.classList.toggle('rtl', isRTL);
|
| 386 |
+
});
|
| 387 |
+
|
| 388 |
+
// Update input placeholder
|
| 389 |
+
messageInput.placeholder = isRTL ? 'اكتب رسالتك هنا...' : 'Type your message here...';
|
| 390 |
+
|
| 391 |
+
// Update welcome message if visible
|
| 392 |
+
if (!welcomeMessage.classList.contains('hidden')) {
|
| 393 |
+
welcomeMessage.querySelector('p').textContent = isRTL
|
| 394 |
+
? 'أنا مساعدك الذكي. اسألني عن أي شيء، وسأبذل قصارى جهدي لمساعدتك!'
|
| 395 |
+
: 'I\'m your intelligent assistant. Ask me anything, and I\'ll do my best to help you!';
|
| 396 |
+
|
| 397 |
+
const suggestionBtns = welcomeMessage.querySelectorAll('.suggestion-btn');
|
| 398 |
+
if (isRTL) {
|
| 399 |
+
suggestionBtns[0].textContent = '"اشرح الحوسبة الكمومية"';
|
| 400 |
+
suggestionBtns[1].textContent = '"اكتب قصيدة عن الذكاء الاصطناعي"';
|
| 401 |
+
suggestionBtns[2].textContent = '"كيف أتعلم جافا سكريبت؟"';
|
| 402 |
+
} else {
|
| 403 |
+
suggestionBtns[0].textContent = '"Explain quantum computing"';
|
| 404 |
+
suggestionBtns[1].textContent = '"Write a poem about AI"';
|
| 405 |
+
suggestionBtns[2].textContent = '"How to learn JavaScript?"';
|
| 406 |
+
}
|
| 407 |
+
}
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
function startNewChat() {
|
| 411 |
+
chatContainer.innerHTML = '';
|
| 412 |
+
chatHistory = [];
|
| 413 |
+
welcomeMessage.classList.remove('hidden');
|
| 414 |
+
chatContainer.classList.add('hidden');
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
function handleSuggestionClick(e) {
|
| 418 |
+
messageInput.value = e.target.textContent.trim().replace(/^"|"$/g, '');
|
| 419 |
+
handleInputChange();
|
| 420 |
+
}
|
| 421 |
+
});
|
| 422 |
+
</script>
|
| 423 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=HAMZACROSS1/ai" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 424 |
+
</html>
|