Update index.html
Browse files- index.html +201 -108
index.html
CHANGED
|
@@ -18,6 +18,9 @@
|
|
| 18 |
line-height: 1.6;
|
| 19 |
letter-spacing: -0.01em;
|
| 20 |
transition: background-color 0.3s, color 0.3s;
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
|
| 23 |
body.light-mode {
|
|
@@ -35,11 +38,6 @@
|
|
| 35 |
border-color: #404040;
|
| 36 |
}
|
| 37 |
|
| 38 |
-
.dark-mode footer {
|
| 39 |
-
background-color: #2d2d2d;
|
| 40 |
-
border-color: #404040;
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
.dark-mode .message-input {
|
| 44 |
background-color: #363636;
|
| 45 |
border-color: #404040;
|
|
@@ -82,6 +80,25 @@
|
|
| 82 |
letter-spacing: -0.02em;
|
| 83 |
}
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
.message {
|
| 86 |
opacity: 0;
|
| 87 |
transform: translateY(20px);
|
|
@@ -142,11 +159,25 @@
|
|
| 142 |
font-size: 0.9em;
|
| 143 |
}
|
| 144 |
|
| 145 |
-
.
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
}
|
| 149 |
|
|
|
|
| 150 |
.modal {
|
| 151 |
display: none;
|
| 152 |
position: fixed;
|
|
@@ -155,45 +186,26 @@
|
|
| 155 |
right: 0;
|
| 156 |
bottom: 0;
|
| 157 |
background-color: rgba(0, 0, 0, 0.5);
|
| 158 |
-
z-index: 1000;
|
| 159 |
-
justify-content: center;
|
| 160 |
align-items: center;
|
|
|
|
|
|
|
| 161 |
}
|
| 162 |
|
| 163 |
.modal-content {
|
| 164 |
background-color: white;
|
| 165 |
padding: 2rem;
|
| 166 |
border-radius: 0.5rem;
|
| 167 |
-
max-width: 600px;
|
| 168 |
width: 90%;
|
| 169 |
-
max-
|
| 170 |
-
overflow-y: auto;
|
| 171 |
}
|
| 172 |
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
.chat-input {
|
| 182 |
-
max-height: 60px;
|
| 183 |
-
min-height: 32px;
|
| 184 |
-
}
|
| 185 |
-
|
| 186 |
-
@keyframes fadeIn {
|
| 187 |
-
to {
|
| 188 |
-
opacity: 1;
|
| 189 |
-
transform: translateY(0);
|
| 190 |
-
}
|
| 191 |
-
}
|
| 192 |
-
|
| 193 |
-
.message-actions {
|
| 194 |
-
margin-top: 0.5rem;
|
| 195 |
-
display: flex;
|
| 196 |
-
gap: 0.5rem;
|
| 197 |
}
|
| 198 |
</style>
|
| 199 |
</head>
|
|
@@ -209,11 +221,6 @@
|
|
| 209 |
<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>
|
| 210 |
</svg>
|
| 211 |
</a>
|
| 212 |
-
<a href="/chats" class="header-button">
|
| 213 |
-
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 214 |
-
<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>
|
| 215 |
-
</svg>
|
| 216 |
-
</a>
|
| 217 |
<button id="darkModeToggle" class="header-button">
|
| 218 |
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 219 |
<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>
|
|
@@ -228,17 +235,69 @@
|
|
| 228 |
</div>
|
| 229 |
</header>
|
| 230 |
|
| 231 |
-
<main
|
| 232 |
-
<div class="max-w-3xl mx-auto px-4">
|
| 233 |
<div class="welcome-text">ุณุจูุฏู ููุง ูู
ุณุงุนุฏุชู</div>
|
| 234 |
-
<div id="messagesContainer" class="space-y-4"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
</div>
|
| 236 |
</main>
|
| 237 |
|
|
|
|
| 238 |
<div id="editModal" class="modal">
|
| 239 |
<div class="modal-content">
|
| 240 |
-
<h2 class="text-
|
| 241 |
-
<textarea id="editText"
|
| 242 |
<div class="flex justify-end gap-2">
|
| 243 |
<button id="cancelEdit" class="px-4 py-2 bg-gray-200 rounded-lg">ุฅูุบุงุก</button>
|
| 244 |
<button id="saveEdit" class="px-4 py-2 bg-black text-white rounded-lg">ุญูุธ</button>
|
|
@@ -246,59 +305,6 @@
|
|
| 246 |
</div>
|
| 247 |
</div>
|
| 248 |
|
| 249 |
-
<footer class="fixed bottom-0 left-0 right-0 bg-white shadow-sm">
|
| 250 |
-
<div class="max-w-3xl mx-auto px-4 py-3">
|
| 251 |
-
<div class="relative bg-white rounded-xl border border-gray-200 p-2">
|
| 252 |
-
<textarea
|
| 253 |
-
id="messageInput"
|
| 254 |
-
class="chat-input w-full text-gray-600 text-lg p-2 rounded-lg resize-none border-none"
|
| 255 |
-
placeholder="ุงูุชุจ ุฑุณุงูุชู ููุง..."
|
| 256 |
-
rows="1"
|
| 257 |
-
></textarea>
|
| 258 |
-
|
| 259 |
-
<div class="flex items-center justify-between mt-2">
|
| 260 |
-
<div class="flex gap-3">
|
| 261 |
-
<button class="text-gray-400 hover:text-gray-600" id="attachButton">
|
| 262 |
-
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
| 263 |
-
<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"/>
|
| 264 |
-
</svg>
|
| 265 |
-
</button>
|
| 266 |
-
<a href="https://joermd-test11.static.hf.space" target="_blank" id="micButton" class="text-gray-400 hover:text-gray-600">
|
| 267 |
-
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
| 268 |
-
<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"/>
|
| 269 |
-
</svg>
|
| 270 |
-
</a>
|
| 271 |
-
<button id="searchButton" class="text-gray-400 hover:text-gray-600">
|
| 272 |
-
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
| 273 |
-
<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"/>
|
| 274 |
-
</svg>
|
| 275 |
-
</button>
|
| 276 |
-
</div>
|
| 277 |
-
|
| 278 |
-
<div class="flex items-center gap-3">
|
| 279 |
-
<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">
|
| 280 |
-
<option value="short">โก ุฑุฏูุฏ ูุตูุฑุฉ</option>
|
| 281 |
-
<option value="normal" selected>โฏ ุนุงุฏู</option>
|
| 282 |
-
<option value="long">โ ุฑุฏูุฏ ู
ูุตูุฉ</option>
|
| 283 |
-
</select>
|
| 284 |
-
|
| 285 |
-
<div class="flex items-center gap-2 bg-gray-50 px-2 py-1 rounded-lg">
|
| 286 |
-
<span class="text-gray-600">ุฐูุงุก ู
ุชูุฏู
</span>
|
| 287 |
-
<div class="toggle-switch" id="aiToggle"></div>
|
| 288 |
-
</div>
|
| 289 |
-
|
| 290 |
-
<button id="sendMessage" class="bg-black text-white px-3 py-1.5 rounded-lg flex items-center gap-2">
|
| 291 |
-
ุฅุฑุณุงู
|
| 292 |
-
<svg class="w-4 h-4 rotate-90" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
| 293 |
-
<path d="M12 19V5M5 12l7-7 7 7"/>
|
| 294 |
-
</svg>
|
| 295 |
-
</button>
|
| 296 |
-
</div>
|
| 297 |
-
</div>
|
| 298 |
-
</div>
|
| 299 |
-
</div>
|
| 300 |
-
</footer>
|
| 301 |
-
|
| 302 |
<script>
|
| 303 |
const API_URL = 'https://975yry7ibyersz-7777.proxy.runpod.net/proxy/8000/chat';
|
| 304 |
const messagesContainer = document.getElementById('messagesContainer');
|
|
@@ -308,6 +314,7 @@
|
|
| 308 |
const styleSelect = document.getElementById('styleSelect');
|
| 309 |
const darkModeToggle = document.getElementById('darkModeToggle');
|
| 310 |
const aiToggle = document.getElementById('aiToggle');
|
|
|
|
| 311 |
const searchButton = document.getElementById('searchButton');
|
| 312 |
const editModal = document.getElementById('editModal');
|
| 313 |
const editText = document.getElementById('editText');
|
|
@@ -319,6 +326,25 @@
|
|
| 319 |
let currentController = null;
|
| 320 |
let isSearchEnabled = false;
|
| 321 |
let currentEditMessageId = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
|
| 323 |
function formatCode(text) {
|
| 324 |
const codeBlockRegex = /```(\w+)?\n([\s\S]*?)```/g;
|
|
@@ -465,15 +491,21 @@
|
|
| 465 |
currentController = new AbortController();
|
| 466 |
toggleSendButton(true);
|
| 467 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
const response = await fetch(API_URL, {
|
| 469 |
method: 'POST',
|
| 470 |
headers: { 'Content-Type': 'application/json' },
|
| 471 |
-
body: JSON.stringify(
|
| 472 |
-
message: actualMessage,
|
| 473 |
-
history: chatHistory,
|
| 474 |
-
advanced: aiToggle.classList.contains('active'),
|
| 475 |
-
search: isSearchEnabled
|
| 476 |
-
}),
|
| 477 |
signal: currentController.signal
|
| 478 |
});
|
| 479 |
|
|
@@ -490,6 +522,8 @@
|
|
| 490 |
human: actualMessage,
|
| 491 |
assistant: data.response
|
| 492 |
});
|
|
|
|
|
|
|
| 493 |
} catch (error) {
|
| 494 |
if (error.name === 'AbortError') {
|
| 495 |
document.getElementById(messageId).textContent = 'ุชู
ุฅููุงู ุงูุชูููุฏ.';
|
|
@@ -550,6 +584,23 @@
|
|
| 550 |
}
|
| 551 |
});
|
| 552 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 553 |
// Event listeners for buttons and inputs
|
| 554 |
sendButton.addEventListener('click', sendMessage);
|
| 555 |
messageInput.addEventListener('keypress', (e) => {
|
|
@@ -593,6 +644,7 @@
|
|
| 593 |
clearButton.addEventListener('click', () => {
|
| 594 |
messagesContainer.innerHTML = '';
|
| 595 |
chatHistory = [];
|
|
|
|
| 596 |
});
|
| 597 |
|
| 598 |
// Initial welcome message
|
|
@@ -600,10 +652,51 @@
|
|
| 600 |
messagesContainer.insertAdjacentHTML('beforeend', createBotMessage('', initialMessageId));
|
| 601 |
typeText(initialMessageId, 'ู
ุฑุญุจุงู! ููู ูู
ูููู ู
ุณุงุนุฏุชู ุงูููู
ุ');
|
| 602 |
|
| 603 |
-
|
| 604 |
-
|
| 605 |
Prism.highlightAll();
|
| 606 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 607 |
</script>
|
| 608 |
</body>
|
| 609 |
</html>
|
|
|
|
| 18 |
line-height: 1.6;
|
| 19 |
letter-spacing: -0.01em;
|
| 20 |
transition: background-color 0.3s, color 0.3s;
|
| 21 |
+
min-height: 100vh;
|
| 22 |
+
display: flex;
|
| 23 |
+
flex-direction: column;
|
| 24 |
}
|
| 25 |
|
| 26 |
body.light-mode {
|
|
|
|
| 38 |
border-color: #404040;
|
| 39 |
}
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
.dark-mode .message-input {
|
| 42 |
background-color: #363636;
|
| 43 |
border-color: #404040;
|
|
|
|
| 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);
|
|
|
|
| 159 |
font-size: 0.9em;
|
| 160 |
}
|
| 161 |
|
| 162 |
+
.chat-input {
|
| 163 |
+
max-height: 60px;
|
| 164 |
+
min-height: 32px;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
@keyframes fadeIn {
|
| 168 |
+
to {
|
| 169 |
+
opacity: 1;
|
| 170 |
+
transform: translateY(0);
|
| 171 |
+
}
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
.message-actions {
|
| 175 |
+
margin-top: 0.5rem;
|
| 176 |
+
display: flex;
|
| 177 |
+
gap: 0.5rem;
|
| 178 |
}
|
| 179 |
|
| 180 |
+
/* Modal styles */
|
| 181 |
.modal {
|
| 182 |
display: none;
|
| 183 |
position: fixed;
|
|
|
|
| 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-width: 500px;
|
|
|
|
| 200 |
}
|
| 201 |
|
| 202 |
+
.modal textarea {
|
| 203 |
+
width: 100%;
|
| 204 |
+
min-height: 200px;
|
| 205 |
+
padding: 0.5rem;
|
| 206 |
+
margin: 1rem 0;
|
| 207 |
+
border: 1px solid #e5e7eb;
|
| 208 |
+
border-radius: 0.375rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
}
|
| 210 |
</style>
|
| 211 |
</head>
|
|
|
|
| 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 |
</div>
|
| 236 |
</header>
|
| 237 |
|
| 238 |
+
<main>
|
| 239 |
+
<div class="max-w-3xl mx-auto px-4 w-full flex flex-col flex-1">
|
| 240 |
<div class="welcome-text">ุณุจูุฏู ููุง ูู
ุณุงุนุฏุชู</div>
|
| 241 |
+
<div id="messagesContainer" class="messages-container space-y-4 flex-1"></div>
|
| 242 |
+
|
| 243 |
+
<div class="input-container">
|
| 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 |
+
<div class="flex items-center gap-3">
|
| 272 |
+
<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">
|
| 273 |
+
<option value="short">โก ุฑุฏูุฏ ูุตูุฑุฉ</option>
|
| 274 |
+
<option value="normal" selected>โฏ ุนุงุฏู</option>
|
| 275 |
+
<option value="long">โ ุฑุฏูุฏ ู
ูุตูุฉ</option>
|
| 276 |
+
</select>
|
| 277 |
+
|
| 278 |
+
<div class="flex items-center gap-2 bg-gray-50 px-2 py-1 rounded-lg">
|
| 279 |
+
<span class="text-gray-600">ุฐูุงุก ู
ุชูุฏู
</span>
|
| 280 |
+
<div class="toggle-switch" id="aiToggle"></div>
|
| 281 |
+
</div>
|
| 282 |
+
|
| 283 |
+
<button id="sendMessage" class="bg-black text-white px-3 py-1.5 rounded-lg flex items-center gap-2">
|
| 284 |
+
ุฅุฑุณุงู
|
| 285 |
+
<svg class="w-4 h-4 rotate-90" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
| 286 |
+
<path d="M12 19V5M5 12l7-7 7 7"/>
|
| 287 |
+
</svg>
|
| 288 |
+
</button>
|
| 289 |
+
</div>
|
| 290 |
+
</div>
|
| 291 |
+
</div>
|
| 292 |
+
</div>
|
| 293 |
</div>
|
| 294 |
</main>
|
| 295 |
|
| 296 |
+
<!-- Edit Modal -->
|
| 297 |
<div id="editModal" class="modal">
|
| 298 |
<div class="modal-content">
|
| 299 |
+
<h2 class="text-lg font-bold mb-2">ุชุนุฏูู ุงูุฑุณุงูุฉ</h2>
|
| 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>
|
|
|
|
| 305 |
</div>
|
| 306 |
</div>
|
| 307 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
<script>
|
| 309 |
const API_URL = 'https://975yry7ibyersz-7777.proxy.runpod.net/proxy/8000/chat';
|
| 310 |
const messagesContainer = document.getElementById('messagesContainer');
|
|
|
|
| 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 |
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;
|
|
|
|
| 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(requestData),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 509 |
signal: currentController.signal
|
| 510 |
});
|
| 511 |
|
|
|
|
| 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 |
}
|
| 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 |
clearButton.addEventListener('click', () => {
|
| 645 |
messagesContainer.innerHTML = '';
|
| 646 |
chatHistory = [];
|
| 647 |
+
uploadedFiles = [];
|
| 648 |
});
|
| 649 |
|
| 650 |
// Initial welcome message
|
|
|
|
| 652 |
messagesContainer.insertAdjacentHTML('beforeend', createBotMessage('', initialMessageId));
|
| 653 |
typeText(initialMessageId, 'ู
ุฑุญุจุงู! ููู ูู
ูููู ู
ุณุงุนุฏุชู ุงูููู
ุ');
|
| 654 |
|
| 655 |
+
// Initialize Prism.js
|
| 656 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 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>
|