Update index.html
Browse files- index.html +218 -190
index.html
CHANGED
@@ -38,6 +38,11 @@
|
|
38 |
border-color: #404040;
|
39 |
}
|
40 |
|
|
|
|
|
|
|
|
|
|
|
41 |
.dark-mode .message-input {
|
42 |
background-color: #363636;
|
43 |
border-color: #404040;
|
@@ -80,25 +85,6 @@
|
|
80 |
letter-spacing: -0.02em;
|
81 |
}
|
82 |
|
83 |
-
main {
|
84 |
-
flex: 1;
|
85 |
-
display: flex;
|
86 |
-
flex-direction: column;
|
87 |
-
padding-top: 4rem;
|
88 |
-
}
|
89 |
-
|
90 |
-
.messages-container {
|
91 |
-
flex: 1;
|
92 |
-
overflow-y: auto;
|
93 |
-
padding: 1rem;
|
94 |
-
}
|
95 |
-
|
96 |
-
.input-container {
|
97 |
-
margin-top: auto;
|
98 |
-
padding: 1rem;
|
99 |
-
background-color: transparent;
|
100 |
-
}
|
101 |
-
|
102 |
.message {
|
103 |
opacity: 0;
|
104 |
transform: translateY(20px);
|
@@ -157,27 +143,96 @@
|
|
157 |
background-color: #f8f9fa;
|
158 |
border-radius: 8px;
|
159 |
font-size: 0.9em;
|
|
|
|
|
160 |
}
|
161 |
|
162 |
-
.
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
}
|
166 |
|
167 |
-
@keyframes
|
168 |
to {
|
169 |
-
|
170 |
-
transform: translateY(0);
|
171 |
}
|
172 |
}
|
173 |
|
174 |
-
.
|
175 |
-
margin
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
179 |
|
180 |
-
/* Modal styles */
|
181 |
.modal {
|
182 |
display: none;
|
183 |
position: fixed;
|
@@ -186,26 +241,75 @@
|
|
186 |
right: 0;
|
187 |
bottom: 0;
|
188 |
background-color: rgba(0, 0, 0, 0.5);
|
189 |
-
align-items: center;
|
190 |
-
justify-content: center;
|
191 |
z-index: 1000;
|
|
|
|
|
192 |
}
|
193 |
|
194 |
.modal-content {
|
195 |
background-color: white;
|
196 |
padding: 2rem;
|
197 |
border-radius: 0.5rem;
|
|
|
198 |
width: 90%;
|
199 |
-
max-
|
|
|
200 |
}
|
201 |
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
}
|
210 |
</style>
|
211 |
</head>
|
@@ -221,6 +325,11 @@
|
|
221 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path>
|
222 |
</svg>
|
223 |
</a>
|
|
|
|
|
|
|
|
|
|
|
224 |
<button id="darkModeToggle" class="header-button">
|
225 |
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
226 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"></path>
|
@@ -235,69 +344,70 @@
|
|
235 |
</div>
|
236 |
</header>
|
237 |
|
238 |
-
<main>
|
239 |
-
<div class="max-w-3xl mx-auto px-4
|
240 |
<div class="welcome-text">سبيدي هنا لمساعدتك</div>
|
241 |
-
<div id="messagesContainer" class="
|
242 |
-
|
243 |
-
|
244 |
-
<div class="bg-white rounded-xl border border-gray-200 p-2">
|
245 |
-
<textarea
|
246 |
-
id="messageInput"
|
247 |
-
class="chat-input w-full text-gray-600 text-lg p-2 rounded-lg resize-none border-none"
|
248 |
-
placeholder="اكتب رسالتك هنا..."
|
249 |
-
rows="1"
|
250 |
-
></textarea>
|
251 |
-
|
252 |
-
<div class="flex items-center justify-between mt-2">
|
253 |
-
<div class="flex gap-3">
|
254 |
-
<button class="text-gray-400 hover:text-gray-600" id="attachButton">
|
255 |
-
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
256 |
-
<path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"/>
|
257 |
-
</svg>
|
258 |
-
</button>
|
259 |
-
<a href="https://joermd-test11.static.hf.space" target="_blank" id="micButton" class="text-gray-400 hover:text-gray-600">
|
260 |
-
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
261 |
-
<path d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"/>
|
262 |
-
</svg>
|
263 |
-
</a>
|
264 |
-
<button id="searchButton" class="text-gray-400 hover:text-gray-600">
|
265 |
-
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
266 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
|
267 |
-
</svg>
|
268 |
-
</button>
|
269 |
-
</div>
|
270 |
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
|
|
|
|
282 |
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
<path d="M12 19V5M5 12l7-7 7 7"/>
|
287 |
-
</svg>
|
288 |
-
</button>
|
289 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
</div>
|
291 |
</div>
|
292 |
</div>
|
293 |
</div>
|
294 |
-
</
|
295 |
|
296 |
-
<!-- Edit Modal -->
|
297 |
<div id="editModal" class="modal">
|
298 |
<div class="modal-content">
|
299 |
-
<h2 class="text-
|
300 |
-
<textarea id="editText"></textarea>
|
301 |
<div class="flex justify-end gap-2">
|
302 |
<button id="cancelEdit" class="px-4 py-2 bg-gray-200 rounded-lg">إلغاء</button>
|
303 |
<button id="saveEdit" class="px-4 py-2 bg-black text-white rounded-lg">حفظ</button>
|
@@ -306,7 +416,7 @@
|
|
306 |
</div>
|
307 |
|
308 |
<script>
|
309 |
-
const API_URL = 'https://
|
310 |
const messagesContainer = document.getElementById('messagesContainer');
|
311 |
const messageInput = document.getElementById('messageInput');
|
312 |
const sendButton = document.getElementById('sendMessage');
|
@@ -314,7 +424,6 @@
|
|
314 |
const styleSelect = document.getElementById('styleSelect');
|
315 |
const darkModeToggle = document.getElementById('darkModeToggle');
|
316 |
const aiToggle = document.getElementById('aiToggle');
|
317 |
-
const attachButton = document.getElementById('attachButton');
|
318 |
const searchButton = document.getElementById('searchButton');
|
319 |
const editModal = document.getElementById('editModal');
|
320 |
const editText = document.getElementById('editText');
|
@@ -326,25 +435,6 @@
|
|
326 |
let currentController = null;
|
327 |
let isSearchEnabled = false;
|
328 |
let currentEditMessageId = null;
|
329 |
-
let uploadedFiles = [];
|
330 |
-
|
331 |
-
async function handleFileUpload(file) {
|
332 |
-
const formData = new FormData();
|
333 |
-
formData.append('file', file);
|
334 |
-
|
335 |
-
try {
|
336 |
-
const response = await fetch(`${API_URL}/upload`, {
|
337 |
-
method: 'POST',
|
338 |
-
body: formData
|
339 |
-
});
|
340 |
-
const data = await response.json();
|
341 |
-
uploadedFiles.push(data.filename);
|
342 |
-
return data.filename;
|
343 |
-
} catch (error) {
|
344 |
-
console.error('Error uploading file:', error);
|
345 |
-
return null;
|
346 |
-
}
|
347 |
-
}
|
348 |
|
349 |
function formatCode(text) {
|
350 |
const codeBlockRegex = /```(\w+)?\n([\s\S]*?)```/g;
|
@@ -357,9 +447,14 @@
|
|
357 |
function createThinkingSteps(messageId) {
|
358 |
return `
|
359 |
<div id="${messageId}-thinking" class="thinking-steps">
|
360 |
-
<div
|
361 |
-
<div
|
362 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
363 |
</div>
|
364 |
`;
|
365 |
}
|
@@ -491,21 +586,15 @@
|
|
491 |
currentController = new AbortController();
|
492 |
toggleSendButton(true);
|
493 |
|
494 |
-
const requestData = {
|
495 |
-
message: actualMessage,
|
496 |
-
history: chatHistory,
|
497 |
-
advanced: aiToggle.classList.contains('active'),
|
498 |
-
search: isSearchEnabled
|
499 |
-
};
|
500 |
-
|
501 |
-
if (uploadedFiles.length > 0) {
|
502 |
-
requestData.files = uploadedFiles;
|
503 |
-
}
|
504 |
-
|
505 |
const response = await fetch(API_URL, {
|
506 |
method: 'POST',
|
507 |
headers: { 'Content-Type': 'application/json' },
|
508 |
-
body: JSON.stringify(
|
|
|
|
|
|
|
|
|
|
|
509 |
signal: currentController.signal
|
510 |
});
|
511 |
|
@@ -522,8 +611,6 @@
|
|
522 |
human: actualMessage,
|
523 |
assistant: data.response
|
524 |
});
|
525 |
-
|
526 |
-
uploadedFiles = [];
|
527 |
} catch (error) {
|
528 |
if (error.name === 'AbortError') {
|
529 |
document.getElementById(messageId).textContent = 'تم إيقاف التوليد.';
|
@@ -584,23 +671,6 @@
|
|
584 |
}
|
585 |
});
|
586 |
|
587 |
-
attachButton.addEventListener('click', () => {
|
588 |
-
const input = document.createElement('input');
|
589 |
-
input.type = 'file';
|
590 |
-
input.accept = '*/*';
|
591 |
-
input.onchange = async (e) => {
|
592 |
-
const file = e.target.files[0];
|
593 |
-
if (file) {
|
594 |
-
const filename = await handleFileUpload(file);
|
595 |
-
if (filename) {
|
596 |
-
messageInput.value += `\nملف مرفق: ${filename}`;
|
597 |
-
adjustTextareaHeight();
|
598 |
-
}
|
599 |
-
}
|
600 |
-
};
|
601 |
-
input.click();
|
602 |
-
});
|
603 |
-
|
604 |
// Event listeners for buttons and inputs
|
605 |
sendButton.addEventListener('click', sendMessage);
|
606 |
messageInput.addEventListener('keypress', (e) => {
|
@@ -644,7 +714,6 @@
|
|
644 |
clearButton.addEventListener('click', () => {
|
645 |
messagesContainer.innerHTML = '';
|
646 |
chatHistory = [];
|
647 |
-
uploadedFiles = [];
|
648 |
});
|
649 |
|
650 |
// Initial welcome message
|
@@ -652,51 +721,10 @@
|
|
652 |
messagesContainer.insertAdjacentHTML('beforeend', createBotMessage('', initialMessageId));
|
653 |
typeText(initialMessageId, 'مرحباً! كيف يمكنني مساعدتك اليوم؟');
|
654 |
|
655 |
-
|
656 |
-
|
657 |
Prism.highlightAll();
|
658 |
});
|
659 |
-
|
660 |
-
// Support for paste events
|
661 |
-
messageInput.addEventListener('paste', (e) => {
|
662 |
-
const files = e.clipboardData.files;
|
663 |
-
if (files.length > 0) {
|
664 |
-
e.preventDefault();
|
665 |
-
handleFileUpload(files[0]).then(filename => {
|
666 |
-
if (filename) {
|
667 |
-
messageInput.value += `\nملف مرفق: ${filename}`;
|
668 |
-
adjustTextareaHeight();
|
669 |
-
}
|
670 |
-
});
|
671 |
-
}
|
672 |
-
});
|
673 |
-
|
674 |
-
// Support for drag and drop
|
675 |
-
messageInput.addEventListener('dragover', (e) => {
|
676 |
-
e.preventDefault();
|
677 |
-
e.stopPropagation();
|
678 |
-
messageInput.classList.add('dragover');
|
679 |
-
});
|
680 |
-
|
681 |
-
messageInput.addEventListener('dragleave', () => {
|
682 |
-
messageInput.classList.remove('dragover');
|
683 |
-
});
|
684 |
-
|
685 |
-
messageInput.addEventListener('drop', (e) => {
|
686 |
-
e.preventDefault();
|
687 |
-
e.stopPropagation();
|
688 |
-
messageInput.classList.remove('dragover');
|
689 |
-
|
690 |
-
const files = e.dataTransfer.files;
|
691 |
-
if (files.length > 0) {
|
692 |
-
handleFileUpload(files[0]).then(filename => {
|
693 |
-
if (filename) {
|
694 |
-
messageInput.value += `\nملف مرفق: ${filename}`;
|
695 |
-
adjustTextareaHeight();
|
696 |
-
}
|
697 |
-
});
|
698 |
-
}
|
699 |
-
});
|
700 |
</script>
|
701 |
</body>
|
702 |
</html>
|
|
|
38 |
border-color: #404040;
|
39 |
}
|
40 |
|
41 |
+
.dark-mode footer {
|
42 |
+
background-color: #2d2d2d;
|
43 |
+
border-color: #404040;
|
44 |
+
}
|
45 |
+
|
46 |
.dark-mode .message-input {
|
47 |
background-color: #363636;
|
48 |
border-color: #404040;
|
|
|
85 |
letter-spacing: -0.02em;
|
86 |
}
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
.message {
|
89 |
opacity: 0;
|
90 |
transform: translateY(20px);
|
|
|
143 |
background-color: #f8f9fa;
|
144 |
border-radius: 8px;
|
145 |
font-size: 0.9em;
|
146 |
+
position: relative;
|
147 |
+
overflow: hidden;
|
148 |
}
|
149 |
|
150 |
+
.thinking-steps::after {
|
151 |
+
content: '';
|
152 |
+
position: absolute;
|
153 |
+
top: 0;
|
154 |
+
left: -100%;
|
155 |
+
width: 100%;
|
156 |
+
height: 100%;
|
157 |
+
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
|
158 |
+
animation: shine 1.5s infinite;
|
159 |
}
|
160 |
|
161 |
+
@keyframes shine {
|
162 |
to {
|
163 |
+
left: 100%;
|
|
|
164 |
}
|
165 |
}
|
166 |
|
167 |
+
.thinking-steps div {
|
168 |
+
margin: 5px 0;
|
169 |
+
color: #666;
|
170 |
+
}
|
171 |
+
|
172 |
+
.loading-indicator {
|
173 |
+
display: inline-block;
|
174 |
+
position: relative;
|
175 |
+
width: 80px;
|
176 |
+
height: 13px;
|
177 |
+
}
|
178 |
+
|
179 |
+
.loading-indicator div {
|
180 |
+
position: absolute;
|
181 |
+
top: 0;
|
182 |
+
width: 13px;
|
183 |
+
height: 13px;
|
184 |
+
border-radius: 50%;
|
185 |
+
background: #3b82f6;
|
186 |
+
animation-timing-function: cubic-bezier(0, 1, 1, 0);
|
187 |
+
}
|
188 |
+
|
189 |
+
.loading-indicator div:nth-child(1) {
|
190 |
+
left: 8px;
|
191 |
+
animation: loading1 0.6s infinite;
|
192 |
+
}
|
193 |
+
|
194 |
+
.loading-indicator div:nth-child(2) {
|
195 |
+
left: 8px;
|
196 |
+
animation: loading2 0.6s infinite;
|
197 |
+
}
|
198 |
+
|
199 |
+
.loading-indicator div:nth-child(3) {
|
200 |
+
left: 32px;
|
201 |
+
animation: loading2 0.6s infinite;
|
202 |
+
}
|
203 |
+
|
204 |
+
.loading-indicator div:nth-child(4) {
|
205 |
+
left: 56px;
|
206 |
+
animation: loading3 0.6s infinite;
|
207 |
+
}
|
208 |
+
|
209 |
+
@keyframes loading1 {
|
210 |
+
0% {
|
211 |
+
transform: scale(0);
|
212 |
+
}
|
213 |
+
100% {
|
214 |
+
transform: scale(1);
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
@keyframes loading3 {
|
219 |
+
0% {
|
220 |
+
transform: scale(1);
|
221 |
+
}
|
222 |
+
100% {
|
223 |
+
transform: scale(0);
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
@keyframes loading2 {
|
228 |
+
0% {
|
229 |
+
transform: translate(0, 0);
|
230 |
+
}
|
231 |
+
100% {
|
232 |
+
transform: translate(24px, 0);
|
233 |
+
}
|
234 |
}
|
235 |
|
|
|
236 |
.modal {
|
237 |
display: none;
|
238 |
position: fixed;
|
|
|
241 |
right: 0;
|
242 |
bottom: 0;
|
243 |
background-color: rgba(0, 0, 0, 0.5);
|
|
|
|
|
244 |
z-index: 1000;
|
245 |
+
justify-content: center;
|
246 |
+
align-items: center;
|
247 |
}
|
248 |
|
249 |
.modal-content {
|
250 |
background-color: white;
|
251 |
padding: 2rem;
|
252 |
border-radius: 0.5rem;
|
253 |
+
max-width: 600px;
|
254 |
width: 90%;
|
255 |
+
max-height: 80vh;
|
256 |
+
overflow-y: auto;
|
257 |
}
|
258 |
|
259 |
+
pre[class*="language-"] {
|
260 |
+
direction: ltr;
|
261 |
+
text-align: left;
|
262 |
+
margin: 1em 0;
|
263 |
+
border-radius: 0.5rem;
|
264 |
+
padding: 1em;
|
265 |
+
}
|
266 |
+
|
267 |
+
.chat-input {
|
268 |
+
max-height: 60px;
|
269 |
+
min-height: 32px;
|
270 |
+
}
|
271 |
+
|
272 |
+
@keyframes fadeIn {
|
273 |
+
to {
|
274 |
+
opacity: 1;
|
275 |
+
transform: translateY(0);
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
.message-actions {
|
280 |
+
margin-top: 0.5rem;
|
281 |
+
display: flex;
|
282 |
+
gap: 0.5rem;
|
283 |
+
}
|
284 |
+
|
285 |
+
main {
|
286 |
+
flex: 1;
|
287 |
+
padding-bottom: 180px; /* Increased padding to accommodate the input area */
|
288 |
+
}
|
289 |
+
|
290 |
+
.input-container {
|
291 |
+
position: fixed;
|
292 |
+
bottom: 0;
|
293 |
+
left: 0;
|
294 |
+
right: 0;
|
295 |
+
background: white;
|
296 |
+
padding: 1rem;
|
297 |
+
border-top: 1px solid #e5e7eb;
|
298 |
+
z-index: 50;
|
299 |
+
}
|
300 |
+
|
301 |
+
@media (max-width: 640px) {
|
302 |
+
.welcome-text {
|
303 |
+
font-size: 1.5rem;
|
304 |
+
}
|
305 |
+
|
306 |
+
.input-container {
|
307 |
+
padding: 0.5rem;
|
308 |
+
}
|
309 |
+
|
310 |
+
.style-select, .toggle-switch-container {
|
311 |
+
font-size: 0.8rem;
|
312 |
+
}
|
313 |
}
|
314 |
</style>
|
315 |
</head>
|
|
|
325 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path>
|
326 |
</svg>
|
327 |
</a>
|
328 |
+
<a href="/chats" class="header-button">
|
329 |
+
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
330 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"></path>
|
331 |
+
</svg>
|
332 |
+
</a>
|
333 |
<button id="darkModeToggle" class="header-button">
|
334 |
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
335 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"></path>
|
|
|
344 |
</div>
|
345 |
</header>
|
346 |
|
347 |
+
<main class="pt-24">
|
348 |
+
<div class="max-w-3xl mx-auto px-4">
|
349 |
<div class="welcome-text">سبيدي هنا لمساعدتك</div>
|
350 |
+
<div id="messagesContainer" class="space-y-4"></div>
|
351 |
+
</div>
|
352 |
+
</main>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
|
354 |
+
<div class="input-container">
|
355 |
+
<div class="max-w-3xl mx-auto">
|
356 |
+
<div class="relative bg-white rounded-xl border border-gray-200 p-2">
|
357 |
+
<textarea
|
358 |
+
id="messageInput"
|
359 |
+
class="chat-input w-full text-gray-600 text-lg p-2 rounded-lg resize-none border-none"
|
360 |
+
placeholder="اك��ب رسالتك هنا..."
|
361 |
+
rows="1"
|
362 |
+
></textarea>
|
363 |
+
|
364 |
+
<div class="flex items-center justify-between mt-2">
|
365 |
+
<div class="flex gap-3">
|
366 |
+
<button class="text-gray-400 hover:text-gray-600" id="attachButton">
|
367 |
+
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
368 |
+
<path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"/>
|
369 |
+
</svg>
|
370 |
+
</button>
|
371 |
+
<a href="https://joermd-test11.static.hf.space" target="_blank" id="micButton" class="text-gray-400 hover:text-gray-600">
|
372 |
+
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
373 |
+
<path d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"/>
|
374 |
+
</svg>
|
375 |
+
</a>
|
376 |
+
<button id="searchButton" class="text-gray-400 hover:text-gray-600">
|
377 |
+
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
378 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
|
379 |
+
</svg>
|
380 |
+
</button>
|
381 |
+
</div>
|
382 |
|
383 |
+
<div class="flex items-center gap-3">
|
384 |
+
<select id="styleSelect" class="style-select bg-gray-50 border border-gray-200 text-gray-600 text-sm rounded-lg pl-8 pr-2 py-2">
|
385 |
+
<option value="short">⚡ ردود قصيرة</option>
|
386 |
+
<option value="normal" selected>◯ عادي</option>
|
387 |
+
<option value="long">↔ ردود مفصلة</option>
|
388 |
+
</select>
|
389 |
|
390 |
+
<div class="flex items-center gap-2 bg-gray-50 px-2 py-1 rounded-lg">
|
391 |
+
<span class="text-gray-600">ذكاء متقدم</span>
|
392 |
+
<div class="toggle-switch" id="aiToggle"></div>
|
|
|
|
|
|
|
393 |
</div>
|
394 |
+
|
395 |
+
<button id="sendMessage" class="bg-black text-white px-3 py-1.5 rounded-lg flex items-center gap-2">
|
396 |
+
إرسال
|
397 |
+
<svg class="w-4 h-4 rotate-90" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
398 |
+
<path d="M12 19V5M5 12l7-7 7 7"/>
|
399 |
+
</svg>
|
400 |
+
</button>
|
401 |
</div>
|
402 |
</div>
|
403 |
</div>
|
404 |
</div>
|
405 |
+
</div>
|
406 |
|
|
|
407 |
<div id="editModal" class="modal">
|
408 |
<div class="modal-content">
|
409 |
+
<h2 class="text-xl font-bold mb-4">تعديل النص</h2>
|
410 |
+
<textarea id="editText" class="w-full h-40 p-2 border rounded-lg mb-4"></textarea>
|
411 |
<div class="flex justify-end gap-2">
|
412 |
<button id="cancelEdit" class="px-4 py-2 bg-gray-200 rounded-lg">إلغاء</button>
|
413 |
<button id="saveEdit" class="px-4 py-2 bg-black text-white rounded-lg">حفظ</button>
|
|
|
416 |
</div>
|
417 |
|
418 |
<script>
|
419 |
+
const API_URL = 'https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/chat';
|
420 |
const messagesContainer = document.getElementById('messagesContainer');
|
421 |
const messageInput = document.getElementById('messageInput');
|
422 |
const sendButton = document.getElementById('sendMessage');
|
|
|
424 |
const styleSelect = document.getElementById('styleSelect');
|
425 |
const darkModeToggle = document.getElementById('darkModeToggle');
|
426 |
const aiToggle = document.getElementById('aiToggle');
|
|
|
427 |
const searchButton = document.getElementById('searchButton');
|
428 |
const editModal = document.getElementById('editModal');
|
429 |
const editText = document.getElementById('editText');
|
|
|
435 |
let currentController = null;
|
436 |
let isSearchEnabled = false;
|
437 |
let currentEditMessageId = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
|
439 |
function formatCode(text) {
|
440 |
const codeBlockRegex = /```(\w+)?\n([\s\S]*?)```/g;
|
|
|
447 |
function createThinkingSteps(messageId) {
|
448 |
return `
|
449 |
<div id="${messageId}-thinking" class="thinking-steps">
|
450 |
+
<div>جاري التفكير وتحليل السؤال...</div>
|
451 |
+
<div>معالجة المعلومات وتجهيز الإجابة...</div>
|
452 |
+
<div class="loading-indicator">
|
453 |
+
<div></div>
|
454 |
+
<div></div>
|
455 |
+
<div></div>
|
456 |
+
<div></div>
|
457 |
+
</div>
|
458 |
</div>
|
459 |
`;
|
460 |
}
|
|
|
586 |
currentController = new AbortController();
|
587 |
toggleSendButton(true);
|
588 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
const response = await fetch(API_URL, {
|
590 |
method: 'POST',
|
591 |
headers: { 'Content-Type': 'application/json' },
|
592 |
+
body: JSON.stringify({
|
593 |
+
message: actualMessage,
|
594 |
+
history: chatHistory,
|
595 |
+
advanced: aiToggle.classList.contains('active'),
|
596 |
+
search: isSearchEnabled
|
597 |
+
}),
|
598 |
signal: currentController.signal
|
599 |
});
|
600 |
|
|
|
611 |
human: actualMessage,
|
612 |
assistant: data.response
|
613 |
});
|
|
|
|
|
614 |
} catch (error) {
|
615 |
if (error.name === 'AbortError') {
|
616 |
document.getElementById(messageId).textContent = 'تم إيقاف التوليد.';
|
|
|
671 |
}
|
672 |
});
|
673 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
// Event listeners for buttons and inputs
|
675 |
sendButton.addEventListener('click', sendMessage);
|
676 |
messageInput.addEventListener('keypress', (e) => {
|
|
|
714 |
clearButton.addEventListener('click', () => {
|
715 |
messagesContainer.innerHTML = '';
|
716 |
chatHistory = [];
|
|
|
717 |
});
|
718 |
|
719 |
// Initial welcome message
|
|
|
721 |
messagesContainer.insertAdjacentHTML('beforeend', createBotMessage('', initialMessageId));
|
722 |
typeText(initialMessageId, 'مرحباً! كيف يمكنني مساعدتك اليوم؟');
|
723 |
|
724 |
+
// Initialize Prism.js
|
725 |
+
document.addEventListener('DOMContentLoaded', () => {
|
726 |
Prism.highlightAll();
|
727 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
728 |
</script>
|
729 |
</body>
|
730 |
</html>
|