Update sss.html
Browse files
sss.html
CHANGED
|
@@ -6,20 +6,16 @@
|
|
| 6 |
<title>Speedy Chat</title>
|
| 7 |
<!-- Tailwind CSS -->
|
| 8 |
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
| 9 |
-
<!--
|
| 10 |
-
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.
|
| 11 |
-
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.
|
| 12 |
-
<
|
| 13 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.
|
| 14 |
-
|
| 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 |
-
/*
|
| 32 |
body.light-mode {
|
| 33 |
background-color: #fafafa;
|
| 34 |
color: #374151;
|
|
@@ -71,25 +67,22 @@
|
|
| 71 |
background-color: #404040;
|
| 72 |
}
|
| 73 |
|
| 74 |
-
/*
|
| 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.
|
| 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:
|
| 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.
|
| 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 |
-
/*
|
| 118 |
.long-text-wrapper {
|
| 119 |
-
max-height:
|
| 120 |
overflow-y: auto;
|
| 121 |
-
padding:
|
| 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 |
-
/*
|
| 134 |
.editor-wrapper {
|
| 135 |
display: none;
|
| 136 |
background: white;
|
| 137 |
border-radius: 0.5rem;
|
| 138 |
margin: 1rem 0;
|
| 139 |
-
box-shadow: 0 4px
|
| 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.
|
| 151 |
-
padding: 0.
|
| 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 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
/*
|
| 214 |
.bot-avatar {
|
| 215 |
-
width:
|
| 216 |
-
height:
|
| 217 |
border-radius: 50%;
|
| 218 |
object-fit: cover;
|
| 219 |
-
border: 2px solid #6366f1;
|
| 220 |
}
|
| 221 |
|
| 222 |
.action-button {
|
| 223 |
-
padding: 0.5rem
|
| 224 |
-
border-radius: 0.
|
| 225 |
transition: all 0.2s;
|
| 226 |
display: inline-flex;
|
| 227 |
align-items: center;
|
| 228 |
gap: 0.5rem;
|
| 229 |
-
font-size: 0.
|
| 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
|
| 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://
|
| 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 |
-
//
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 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 |
-
|
| 359 |
-
|
| 360 |
-
|
| 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="
|
| 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
|
| 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 |
-
//
|
| 429 |
-
const codeBlockRegex = /```(\w+)
|
| 430 |
let lastIndex = 0;
|
| 431 |
let match;
|
| 432 |
|
|
@@ -437,10 +345,9 @@
|
|
| 437 |
await addTextWithEditor(element, beforeText);
|
| 438 |
}
|
| 439 |
|
| 440 |
-
// Add code block
|
| 441 |
-
const language = match
|
| 442 |
-
|
| 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
|
| 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 |
-
|
| 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/tailwindcss@2.2.19/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) {
|