joermd commited on
Commit
fcc36da
·
verified ·
1 Parent(s): 8066b2e

Update sss.html

Browse files
Files changed (1) hide show
  1. sss.html +72 -165
sss.html CHANGED
@@ -6,20 +6,16 @@
6
  <title>Speedy Chat</title>
7
  <!-- Tailwind CSS -->
8
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
9
- <!-- Updated Prism.js theme and plugins -->
10
- <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-okaidia.min.css" rel="stylesheet">
11
- <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css" rel="stylesheet">
12
- <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.css" rel="stylesheet">
13
- <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
14
- <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
15
- <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.js"></script>
16
- <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script>
17
- <!-- Enhanced TinyMCE -->
18
  <script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.10.7/tinymce.min.js"></script>
19
  <style>
20
  @import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@100;200;300;400;500;600;700&display=swap');
21
  @import url('https://fonts.googleapis.com/css2?family=Noto+Kufi+Arabic:wght@100;200;300;400;500;600;700;800;900&display=swap');
22
- @import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap');
23
 
24
  body {
25
  font-family: 'IBM Plex Sans Arabic', sans-serif;
@@ -28,7 +24,7 @@
28
  transition: background-color 0.3s, color 0.3s;
29
  }
30
 
31
- /* Enhanced Light/Dark Mode Styles */
32
  body.light-mode {
33
  background-color: #fafafa;
34
  color: #374151;
@@ -71,25 +67,22 @@
71
  background-color: #404040;
72
  }
73
 
74
- /* Enhanced Code Block Styles */
75
  pre[class*="language-"] {
76
  direction: ltr;
77
  text-align: left;
78
  border-radius: 0.5rem;
79
  margin: 1rem 0;
80
  padding: 1rem;
81
- font-size: 0.95rem;
82
  line-height: 1.5;
83
- font-family: 'Fira Code', monospace;
84
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
85
  }
86
 
87
  .code-block-wrapper {
88
  position: relative;
89
- margin: 1.5rem 0;
90
  border-radius: 0.5rem;
91
  overflow: hidden;
92
- border: 1px solid #2d2d2d;
93
  }
94
 
95
  .code-block-header {
@@ -98,64 +91,33 @@
98
  align-items: center;
99
  background: #2d2d2d;
100
  color: white;
101
- padding: 0.75rem 1rem;
102
- font-family: 'Fira Code', monospace;
103
- font-size: 0.9rem;
104
- }
105
-
106
- .code-block-header .language-label {
107
- display: flex;
108
- align-items: center;
109
- gap: 0.5rem;
110
- }
111
-
112
- .code-block-header .language-icon {
113
- width: 16px;
114
- height: 16px;
115
  }
116
 
117
- /* Enhanced Text Content Styles */
118
  .long-text-wrapper {
119
- max-height: 500px;
120
  overflow-y: auto;
121
- padding: 1.25rem;
122
  background: #f8f9fa;
123
  border-radius: 0.5rem;
124
  margin: 1rem 0;
125
- line-height: 1.7;
126
- font-size: 1.1rem;
127
- }
128
-
129
- .dark-mode .long-text-wrapper {
130
- background: #2d2d2d;
131
  }
132
 
133
- /* Enhanced Editor Styles */
134
  .editor-wrapper {
135
  display: none;
136
  background: white;
137
  border-radius: 0.5rem;
138
  margin: 1rem 0;
139
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
140
- border: 1px solid #e5e7eb;
141
- }
142
-
143
- .dark-mode .editor-wrapper {
144
- background: #2d2d2d;
145
- border-color: #404040;
146
  }
147
 
148
  .editor-toolbar {
149
  display: flex;
150
- gap: 0.75rem;
151
- padding: 0.75rem;
152
  border-bottom: 1px solid #e5e7eb;
153
- background: #f8f9fa;
154
- }
155
-
156
- .dark-mode .editor-toolbar {
157
- background: #363636;
158
- border-color: #404040;
159
  }
160
 
161
  /* Message Input Styles */
@@ -163,46 +125,30 @@
163
  resize: none;
164
  min-height: 50px;
165
  max-height: 200px;
166
- transition: all 0.3s ease;
167
  }
168
 
169
  .message-input:focus {
170
  outline: none;
171
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
172
- border-color: #6366f1;
173
  }
174
 
175
- /* Enhanced Message Styles */
 
 
 
 
 
 
 
 
 
 
176
  .message {
177
  opacity: 0;
178
  transform: translateY(20px);
179
  animation: fadeIn 0.3s ease forwards;
180
- margin-bottom: 1.5rem;
181
- }
182
-
183
- .message .bot-message,
184
- .message .user-message {
185
- border-radius: 1rem;
186
- padding: 1.25rem;
187
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
188
- }
189
-
190
- .message .bot-message {
191
- background: white;
192
- border: 1px solid #e5e7eb;
193
- }
194
-
195
- .dark-mode .message .bot-message {
196
- background: #363636;
197
- border-color: #404040;
198
  }
199
 
200
- .message .user-message {
201
- background: #6366f1;
202
- color: white;
203
- }
204
-
205
- /* Animation Keyframes */
206
  @keyframes fadeIn {
207
  to {
208
  opacity: 1;
@@ -210,31 +156,28 @@
210
  }
211
  }
212
 
213
- /* Enhanced Utility Classes */
214
  .bot-avatar {
215
- width: 44px;
216
- height: 44px;
217
  border-radius: 50%;
218
  object-fit: cover;
219
- border: 2px solid #6366f1;
220
  }
221
 
222
  .action-button {
223
- padding: 0.5rem 0.75rem;
224
- border-radius: 0.5rem;
225
  transition: all 0.2s;
226
  display: inline-flex;
227
  align-items: center;
228
  gap: 0.5rem;
229
- font-size: 0.9rem;
230
  color: #6B7280;
231
  background-color: #F3F4F6;
232
- border: 1px solid #E5E7EB;
233
  }
234
 
235
  .action-button:hover {
236
  background-color: #E5E7EB;
237
- transform: translateY(-1px);
238
  }
239
 
240
  .style-select {
@@ -243,39 +186,6 @@
243
  background-repeat: no-repeat;
244
  background-position: left 0.5rem center;
245
  background-size: 1em;
246
- padding-left: 2.5rem;
247
- }
248
-
249
- /* Scrollbar Styles */
250
- ::-webkit-scrollbar {
251
- width: 8px;
252
- height: 8px;
253
- }
254
-
255
- ::-webkit-scrollbar-track {
256
- background: #f1f1f1;
257
- border-radius: 4px;
258
- }
259
-
260
- ::-webkit-scrollbar-thumb {
261
- background: #888;
262
- border-radius: 4px;
263
- }
264
-
265
- ::-webkit-scrollbar-thumb:hover {
266
- background: #666;
267
- }
268
-
269
- .dark-mode ::-webkit-scrollbar-track {
270
- background: #2d2d2d;
271
- }
272
-
273
- .dark-mode ::-webkit-scrollbar-thumb {
274
- background: #666;
275
- }
276
-
277
- .dark-mode ::-webkit-scrollbar-thumb:hover {
278
- background: #888;
279
  }
280
  </style>
281
  </head>
@@ -322,7 +232,7 @@
322
  </button>
323
  <a href="https://joermd-test11.static.hf.space" target="_blank" id="micButton" class="bg-green-500 hover:bg-green-600 text-white rounded-full p-2 transition-colors">
324
  <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
325
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 33 0 116 0v6a3 3 0 01-3 3z"></path>
326
  </svg>
327
  </a>
328
  <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 focus:outline-none focus:ring-2 focus:ring-indigo-200">
@@ -336,7 +246,7 @@
336
  </footer>
337
 
338
  <script>
339
- const API_URL = 'https://nvgsxt9jqx730v-7777.proxy.runpod.net/proxy/8000/chat';
340
  const messagesContainer = document.getElementById('messagesContainer');
341
  const messageInput = document.getElementById('messageInput');
342
  const sendButton = document.getElementById('sendMessage');
@@ -347,38 +257,21 @@
347
  let currentStyle = 'normal';
348
  let currentController = null;
349
 
350
- // Language Icons Map
351
- const languageIcons = {
352
- javascript: '<svg class="language-icon" viewBox="0 0 24 24"><path fill="#F7DF1E" d="M0 0h24v24H0V0zm22.034 18.276c-.175-1.095-.888-2.015-3.003-2.873-.736-.345-1.554-.585-1.797-1.14-.091-.33-.105-.51-.046-.705.15-.646.915-.84 1.515-.66.39.12.75.42.976.9 1.034-.676 1.034-.676 1.755-1.125-.27-.42-.404-.601-.586-.78-.63-.705-1.469-1.065-2.834-1.034l-.705.089c-.676.165-1.32.525-1.71 1.005-1.14 1.291-.811 3.541.569 4.471 1.365 1.02 3.361 1.244 3.616 2.205.24 1.17-.87 1.545-1.966 1.41-.811-.18-1.26-.586-1.755-1.336l-1.83 1.051c.21.48.45.689.81 1.109 1.74 1.756 6.09 1.666 6.871-1.004.029-.09.24-.705.074-1.65l.046.067zm-8.983-7.245h-2.248c0 1.938-.009 3.864-.009 5.805 0 1.232.063 2.363-.138 2.711-.33.689-1.18.601-1.566.48-.396-.196-.597-.466-.83-.855-.063-.105-.11-.196-.127-.196l-1.825 1.125c.305.63.75 1.172 1.324 1.517.855.51 2.004.675 3.207.405.783-.226 1.458-.691 1.811-1.411.51-.93.402-2.07.397-3.346.012-2.054 0-4.109 0-6.179l.004-.056z"/></svg>',
353
- python: '<svg class="language-icon" viewBox="0 0 24 24"><path fill="#3776AB" d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09-.33.22zM21.1 6.11l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01.21.03zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08-.33.23z"/></svg>',
354
- html: '<svg class="language-icon" viewBox="0 0 24 24"><path fill="#E34F26" d="M1.5 0h21l-1.91 21.563L11.977 24l-8.564-2.438L1.5 0zm7.031 9.75l-.232-2.718 10.059.003.23-2.622L5.412 4.41l.698 8.01h9.126l-.326 3.426-2.91.804-2.955-.81-.188-2.11H6.248l.33 4.171L12 19.351l5.379-1.443.744-8.157H8.531z"/></svg>',
355
- css: '<svg class="language-icon" viewBox="0 0 24 24"><path fill="#1572B6" d="M1.5 0h21l-1.91 21.563L11.977 24l-8.565-2.438L1.5 0zm17.09 4.413L5.41 4.41l.213 2.622 10.125.002-.255 2.716h-6.64l.24 2.573h6.182l-.366 3.523-2.91.804-2.956-.81-.188-2.11h-2.61l.29 3.855L12 19.288l5.373-1.53L18.59 4.414z"/></svg>'
356
- };
357
 
358
- function formatCodeBlock(code, language) {
359
- const langIcon = languageIcons[language.toLowerCase()] || '';
360
- return `
361
- <div class="code-block-wrapper">
362
- <div class="code-block-header">
363
- <div class="language-label">
364
- ${langIcon}
365
- <span>${language}</span>
366
- </div>
367
- <button class="copy-code-btn">
368
- <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
369
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2"></path>
370
- </svg>
371
- </button>
372
- </div>
373
- <pre class="line-numbers"><code class="language-${language}">${code}</code></pre>
374
- </div>`;
375
- }
376
 
377
  function createUserMessage(text) {
378
  return `
379
  <div class="message flex justify-end mb-4">
380
  <div class="max-w-[80%]">
381
- <div class="user-message">
382
  <p class="text-lg">${text}</p>
383
  </div>
384
  </div>
@@ -393,12 +286,12 @@
393
  <img src="https://ufastpro.com/wp-content/uploads/2024/12/3.png" alt="Bot Avatar" class="bot-avatar">
394
  </div>
395
  <div class="max-w-[80%] mr-3">
396
- <div class="bot-message">
397
  <p id="${messageId}" class="text-gray-700"></p>
398
- <div class="message-actions mt-3 flex flex-wrap gap-2">
399
  <button class="action-button copy-button" data-message-id="${messageId}">
400
  <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
401
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2"></path>
402
  </svg>
403
  نسخ
404
  </button>
@@ -421,12 +314,27 @@
421
  `;
422
  }
423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  async function typeText(elementId, text) {
425
  const element = document.getElementById(elementId);
426
  element.innerHTML = '';
427
 
428
- // Enhanced code block detection with multiple languages
429
- const codeBlockRegex = /```(\w+)?\n([\s\S]+?)```/g;
430
  let lastIndex = 0;
431
  let match;
432
 
@@ -437,10 +345,9 @@
437
  await addTextWithEditor(element, beforeText);
438
  }
439
 
440
- // Add code block with proper language
441
- const language = match[1] || 'text';
442
- const code = match[2].trim();
443
- element.innerHTML += formatCodeBlock(code, language);
444
  lastIndex = match.index + match[0].length;
445
  }
446
 
@@ -450,7 +357,7 @@
450
  await addTextWithEditor(element, remainingText);
451
  }
452
 
453
- // Initialize Prism.js for all code blocks
454
  Prism.highlightAllUnder(element);
455
  }
456
 
@@ -472,13 +379,13 @@
472
  element.appendChild(textWrapper);
473
  element.appendChild(editorWrapper);
474
 
475
- // Initialize TinyMCE
476
  tinymce.init({
477
  selector: '.tinymce-editor:last',
478
  directionality: 'rtl',
479
  height: 400,
480
  menubar: false,
481
- plugins: 'lists link table',
482
  toolbar: 'undo redo | formatselect | bold italic | alignleft aligncenter alignright | bullist numlist | link table',
483
  content_style: 'body { font-family: "IBM Plex Sans Arabic", sans-serif; }',
484
  setup: function(editor) {
 
6
  <title>Speedy Chat</title>
7
  <!-- Tailwind CSS -->
8
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
9
+ <!-- Prism.js for code highlighting -->
10
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/themes/prism-tomorrow.min.css" rel="stylesheet">
11
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/plugins/line-numbers/prism-line-numbers.min.css" rel="stylesheet">
12
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/prism.min.js"></script>
13
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/plugins/line-numbers/prism-line-numbers.min.js"></script>
14
+ <!-- TinyMCE for rich text editing -->
 
 
 
15
  <script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.10.7/tinymce.min.js"></script>
16
  <style>
17
  @import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@100;200;300;400;500;600;700&display=swap');
18
  @import url('https://fonts.googleapis.com/css2?family=Noto+Kufi+Arabic:wght@100;200;300;400;500;600;700;800;900&display=swap');
 
19
 
20
  body {
21
  font-family: 'IBM Plex Sans Arabic', sans-serif;
 
24
  transition: background-color 0.3s, color 0.3s;
25
  }
26
 
27
+ /* Light/Dark Mode Styles */
28
  body.light-mode {
29
  background-color: #fafafa;
30
  color: #374151;
 
67
  background-color: #404040;
68
  }
69
 
70
+ /* Code Block Styles */
71
  pre[class*="language-"] {
72
  direction: ltr;
73
  text-align: left;
74
  border-radius: 0.5rem;
75
  margin: 1rem 0;
76
  padding: 1rem;
77
+ font-size: 0.9rem;
78
  line-height: 1.5;
 
 
79
  }
80
 
81
  .code-block-wrapper {
82
  position: relative;
83
+ margin: 1rem 0;
84
  border-radius: 0.5rem;
85
  overflow: hidden;
 
86
  }
87
 
88
  .code-block-header {
 
91
  align-items: center;
92
  background: #2d2d2d;
93
  color: white;
94
+ padding: 0.5rem 1rem;
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
96
 
97
+ /* Long Text Styles */
98
  .long-text-wrapper {
99
+ max-height: 300px;
100
  overflow-y: auto;
101
+ padding: 1rem;
102
  background: #f8f9fa;
103
  border-radius: 0.5rem;
104
  margin: 1rem 0;
 
 
 
 
 
 
105
  }
106
 
107
+ /* Rich Text Editor Styles */
108
  .editor-wrapper {
109
  display: none;
110
  background: white;
111
  border-radius: 0.5rem;
112
  margin: 1rem 0;
113
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
 
 
 
 
 
 
114
  }
115
 
116
  .editor-toolbar {
117
  display: flex;
118
+ gap: 0.5rem;
119
+ padding: 0.5rem;
120
  border-bottom: 1px solid #e5e7eb;
 
 
 
 
 
 
121
  }
122
 
123
  /* Message Input Styles */
 
125
  resize: none;
126
  min-height: 50px;
127
  max-height: 200px;
 
128
  }
129
 
130
  .message-input:focus {
131
  outline: none;
132
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
 
133
  }
134
 
135
+ /* Welcome Text Style */
136
+ .welcome-text {
137
+ font-family: 'Noto Kufi Arabic', sans-serif;
138
+ font-size: 2rem;
139
+ font-weight: 700;
140
+ text-align: center;
141
+ margin: 1.5rem 0;
142
+ letter-spacing: -0.02em;
143
+ }
144
+
145
+ /* Message Animation */
146
  .message {
147
  opacity: 0;
148
  transform: translateY(20px);
149
  animation: fadeIn 0.3s ease forwards;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  }
151
 
 
 
 
 
 
 
152
  @keyframes fadeIn {
153
  to {
154
  opacity: 1;
 
156
  }
157
  }
158
 
159
+ /* Utility Classes */
160
  .bot-avatar {
161
+ width: 40px;
162
+ height: 40px;
163
  border-radius: 50%;
164
  object-fit: cover;
 
165
  }
166
 
167
  .action-button {
168
+ padding: 0.5rem;
169
+ border-radius: 0.375rem;
170
  transition: all 0.2s;
171
  display: inline-flex;
172
  align-items: center;
173
  gap: 0.5rem;
174
+ font-size: 0.875rem;
175
  color: #6B7280;
176
  background-color: #F3F4F6;
 
177
  }
178
 
179
  .action-button:hover {
180
  background-color: #E5E7EB;
 
181
  }
182
 
183
  .style-select {
 
186
  background-repeat: no-repeat;
187
  background-position: left 0.5rem center;
188
  background-size: 1em;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  }
190
  </style>
191
  </head>
 
232
  </button>
233
  <a href="https://joermd-test11.static.hf.space" target="_blank" id="micButton" class="bg-green-500 hover:bg-green-600 text-white rounded-full p-2 transition-colors">
234
  <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
235
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 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"></path>
236
  </svg>
237
  </a>
238
  <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 focus:outline-none focus:ring-2 focus:ring-indigo-200">
 
246
  </footer>
247
 
248
  <script>
249
+ const API_URL = 'https://6xcf3eufsiktmf-7777.proxy.runpod.net/proxy/8000/chat';
250
  const messagesContainer = document.getElementById('messagesContainer');
251
  const messageInput = document.getElementById('messageInput');
252
  const sendButton = document.getElementById('sendMessage');
 
257
  let currentStyle = 'normal';
258
  let currentController = null;
259
 
260
+ // Dark mode toggle
261
+ darkModeToggle.addEventListener('click', () => {
262
+ document.body.classList.toggle('dark-mode');
263
+ document.body.classList.toggle('light-mode');
264
+ });
 
 
265
 
266
+ styleSelect.addEventListener('change', (e) => {
267
+ currentStyle = e.target.value;
268
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
 
270
  function createUserMessage(text) {
271
  return `
272
  <div class="message flex justify-end mb-4">
273
  <div class="max-w-[80%]">
274
+ <div class="bg-indigo-500 text-white rounded-lg p-4 shadow-sm">
275
  <p class="text-lg">${text}</p>
276
  </div>
277
  </div>
 
286
  <img src="https://ufastpro.com/wp-content/uploads/2024/12/3.png" alt="Bot Avatar" class="bot-avatar">
287
  </div>
288
  <div class="max-w-[80%] mr-3">
289
+ <div class="bot-message bg-white rounded-lg p-4 shadow-sm">
290
  <p id="${messageId}" class="text-gray-700"></p>
291
+ <div class="message-actions">
292
  <button class="action-button copy-button" data-message-id="${messageId}">
293
  <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
294
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"></path>
295
  </svg>
296
  نسخ
297
  </button>
 
314
  `;
315
  }
316
 
317
+ function formatCodeBlock(code, language) {
318
+ return `
319
+ <div class="code-block-wrapper">
320
+ <div class="code-block-header">
321
+ <span>${language}</span>
322
+ <button class="copy-code-btn">
323
+ <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
324
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2"></path>
325
+ </svg>
326
+ </button>
327
+ </div>
328
+ <pre class="line-numbers"><code class="language-${language}">${code}</code></pre>
329
+ </div>`;
330
+ }
331
+
332
  async function typeText(elementId, text) {
333
  const element = document.getElementById(elementId);
334
  element.innerHTML = '';
335
 
336
+ // Check if text contains code blocks
337
+ const codeBlockRegex = /```(\w+)\n([\s\S]+?)```/g;
338
  let lastIndex = 0;
339
  let match;
340
 
 
345
  await addTextWithEditor(element, beforeText);
346
  }
347
 
348
+ // Add code block
349
+ const [, language, code] = match;
350
+ element.innerHTML += formatCodeBlock(code.trim(), language);
 
351
  lastIndex = match.index + match[0].length;
352
  }
353
 
 
357
  await addTextWithEditor(element, remainingText);
358
  }
359
 
360
+ // Initialize Prism.js
361
  Prism.highlightAllUnder(element);
362
  }
363
 
 
379
  element.appendChild(textWrapper);
380
  element.appendChild(editorWrapper);
381
 
382
+ // Initialize TinyMCE for this textarea
383
  tinymce.init({
384
  selector: '.tinymce-editor:last',
385
  directionality: 'rtl',
386
  height: 400,
387
  menubar: false,
388
+ plugins: 'lists link table',
389
  toolbar: 'undo redo | formatselect | bold italic | alignleft aligncenter alignright | bullist numlist | link table',
390
  content_style: 'body { font-family: "IBM Plex Sans Arabic", sans-serif; }',
391
  setup: function(editor) {