Update index.html
Browse files- index.html +86 -151
index.html
CHANGED
|
@@ -17,7 +17,6 @@
|
|
| 17 |
flex-direction: column;
|
| 18 |
min-height: 100vh;
|
| 19 |
}
|
| 20 |
-
|
| 21 |
.container {
|
| 22 |
flex: 1;
|
| 23 |
display: flex;
|
|
@@ -26,14 +25,12 @@
|
|
| 26 |
overflow-y: auto;
|
| 27 |
scroll-behavior: smooth;
|
| 28 |
}
|
| 29 |
-
|
| 30 |
.message-container {
|
| 31 |
display: flex;
|
| 32 |
flex-direction: column;
|
| 33 |
gap: 20px;
|
| 34 |
align-items: flex-start;
|
| 35 |
}
|
| 36 |
-
|
| 37 |
.message {
|
| 38 |
max-width: 80%;
|
| 39 |
padding: 15px 20px;
|
|
@@ -46,12 +43,10 @@
|
|
| 46 |
background: #fff;
|
| 47 |
transition: all 0.3s ease-in-out;
|
| 48 |
}
|
| 49 |
-
|
| 50 |
.message:hover {
|
| 51 |
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
|
| 52 |
transform: translateY(-3px);
|
| 53 |
}
|
| 54 |
-
|
| 55 |
.message::after {
|
| 56 |
content: '';
|
| 57 |
position: absolute;
|
|
@@ -63,25 +58,21 @@
|
|
| 63 |
opacity: 0;
|
| 64 |
transition: opacity 0.3s ease-in-out;
|
| 65 |
}
|
| 66 |
-
|
| 67 |
.message:hover::after {
|
| 68 |
opacity: 1;
|
| 69 |
}
|
| 70 |
-
|
| 71 |
.user-message {
|
| 72 |
background-color: #e0f7fa;
|
| 73 |
color: #00796b;
|
| 74 |
align-self: flex-end;
|
| 75 |
border-radius: 20px 20px 0 20px;
|
| 76 |
}
|
| 77 |
-
|
| 78 |
.bot-message {
|
| 79 |
background-color: #4c51bf;
|
| 80 |
color: #fff;
|
| 81 |
align-self: flex-start;
|
| 82 |
border-radius: 20px 20px 20px 0;
|
| 83 |
}
|
| 84 |
-
|
| 85 |
@media (max-width: 768px) {
|
| 86 |
.message {
|
| 87 |
max-width: 90%;
|
|
@@ -89,7 +80,6 @@
|
|
| 89 |
border-radius: 15px;
|
| 90 |
}
|
| 91 |
}
|
| 92 |
-
|
| 93 |
.input-container {
|
| 94 |
position: fixed;
|
| 95 |
bottom: 40px;
|
|
@@ -111,7 +101,6 @@
|
|
| 111 |
filter: blur(1px);
|
| 112 |
-webkit-filter: blur(1px);
|
| 113 |
}
|
| 114 |
-
|
| 115 |
.input-container:hover {
|
| 116 |
box-shadow: 0 100px 200px rgba(0, 0, 0, 0.5);
|
| 117 |
transform: translateY(-1px) scale(1.01);
|
|
@@ -119,7 +108,6 @@
|
|
| 119 |
filter: blur(0px);
|
| 120 |
-webkit-filter: blur(0px);
|
| 121 |
}
|
| 122 |
-
|
| 123 |
.input-container>textarea {
|
| 124 |
flex: 1;
|
| 125 |
border: none;
|
|
@@ -133,19 +121,15 @@
|
|
| 133 |
outline: none;
|
| 134 |
box-shadow: none;
|
| 135 |
resize: none;
|
| 136 |
-
|
| 137 |
}
|
| 138 |
-
|
| 139 |
.input-container>textarea:focus {
|
| 140 |
box-shadow: 0 0 0 4px rgba(0, 168, 255, 0.3);
|
| 141 |
}
|
| 142 |
-
|
| 143 |
.input-container>textarea::placeholder {
|
| 144 |
color: #666;
|
| 145 |
opacity: 1;
|
| 146 |
font-weight: 500;
|
| 147 |
}
|
| 148 |
-
|
| 149 |
.input-container::before {
|
| 150 |
content: '';
|
| 151 |
position: absolute;
|
|
@@ -159,50 +143,39 @@
|
|
| 159 |
transition: opacity 0.8s ease, transform 0.8s ease;
|
| 160 |
pointer-events: none;
|
| 161 |
}
|
| 162 |
-
|
| 163 |
.input-container:hover::before {
|
| 164 |
opacity: 0;
|
| 165 |
transform: scale(1.05);
|
| 166 |
}
|
| 167 |
-
|
| 168 |
@keyframes pulse {
|
| 169 |
-
|
| 170 |
0%,
|
| 171 |
100% {
|
| 172 |
box-shadow: 0 0 0 0 rgba(0, 168, 255, 0.5);
|
| 173 |
}
|
| 174 |
-
|
| 175 |
50% {
|
| 176 |
box-shadow: 0 0 0 6px rgba(0, 168, 255, 0);
|
| 177 |
}
|
| 178 |
}
|
| 179 |
-
|
| 180 |
.input-container:focus-within {
|
| 181 |
animation: pulse 2s infinite ease-in-out;
|
| 182 |
}
|
| 183 |
-
|
| 184 |
.input-container>textarea::-webkit-scrollbar {
|
| 185 |
width: 8px;
|
| 186 |
}
|
| 187 |
-
|
| 188 |
.input-container>textarea::-webkit-scrollbar-track {
|
| 189 |
background: #f0f0f0;
|
| 190 |
}
|
| 191 |
-
|
| 192 |
.input-container>textarea::-webkit-scrollbar-thumb {
|
| 193 |
background: #bbb;
|
| 194 |
border-radius: 8px;
|
| 195 |
border: 2px solid #f0f0f0;
|
| 196 |
}
|
| 197 |
-
|
| 198 |
.input-container>textarea::-webkit-scrollbar-thumb:hover {
|
| 199 |
background: #999;
|
| 200 |
}
|
| 201 |
-
|
| 202 |
.input-container>textarea::-webkit-scrollbar-corner {
|
| 203 |
background: transparent;
|
| 204 |
}
|
| 205 |
-
|
| 206 |
.message-input {
|
| 207 |
flex: 1;
|
| 208 |
border: none;
|
|
@@ -210,7 +183,6 @@
|
|
| 210 |
font-size: 16px;
|
| 211 |
padding: 10px;
|
| 212 |
}
|
| 213 |
-
|
| 214 |
.btn-send {
|
| 215 |
background-color: #4c51bf;
|
| 216 |
color: #fff;
|
|
@@ -221,16 +193,13 @@
|
|
| 221 |
cursor: pointer;
|
| 222 |
transition: background-color 0.3s;
|
| 223 |
}
|
| 224 |
-
|
| 225 |
.btn-send[disabled] {
|
| 226 |
background-color: #ccc;
|
| 227 |
cursor: not-allowed;
|
| 228 |
}
|
| 229 |
-
|
| 230 |
.btn-send:hover {
|
| 231 |
background-color: #3730a3;
|
| 232 |
}
|
| 233 |
-
|
| 234 |
/* Base styles */
|
| 235 |
:root {
|
| 236 |
--primary-color: #ffffff;
|
|
@@ -244,7 +213,6 @@
|
|
| 244 |
--arrow-size: 16px;
|
| 245 |
--font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 246 |
}
|
| 247 |
-
|
| 248 |
/* Resetting default styles */
|
| 249 |
* {
|
| 250 |
box-sizing: border-box;
|
|
@@ -252,7 +220,6 @@
|
|
| 252 |
padding: 0;
|
| 253 |
font-family: var(--font-family);
|
| 254 |
}
|
| 255 |
-
|
| 256 |
/* Styling the dropdown button with shadow */
|
| 257 |
.dropbtn {
|
| 258 |
background-color: var(--primary-color);
|
|
@@ -268,7 +235,6 @@
|
|
| 268 |
padding-right: 50px;
|
| 269 |
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
|
| 270 |
}
|
| 271 |
-
|
| 272 |
.dropbtn::after {
|
| 273 |
content: '▲';
|
| 274 |
font-size: var(--arrow-size);
|
|
@@ -278,21 +244,17 @@
|
|
| 278 |
transform: translateY(-50%);
|
| 279 |
transition: transform var(--transition-duration), content var(--transition-duration);
|
| 280 |
}
|
| 281 |
-
|
| 282 |
.dropbtn.active::after {
|
| 283 |
content: '▼';
|
| 284 |
transform: translateY(-50%);
|
| 285 |
}
|
| 286 |
-
|
| 287 |
.dropbtn:hover {
|
| 288 |
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.3);
|
| 289 |
}
|
| 290 |
-
|
| 291 |
.dropdown {
|
| 292 |
position: relative;
|
| 293 |
display: inline-block;
|
| 294 |
}
|
| 295 |
-
|
| 296 |
.dropdown-content {
|
| 297 |
display: none;
|
| 298 |
position: absolute;
|
|
@@ -304,7 +266,6 @@
|
|
| 304 |
overflow: hidden;
|
| 305 |
transition: all var(--transition-duration);
|
| 306 |
}
|
| 307 |
-
|
| 308 |
.dropdown-content a {
|
| 309 |
display: flex;
|
| 310 |
align-items: center;
|
|
@@ -313,205 +274,179 @@
|
|
| 313 |
color: var(--text-color);
|
| 314 |
transition: background-color var(--transition-duration);
|
| 315 |
}
|
| 316 |
-
|
| 317 |
.dropdown-content a .icon {
|
| 318 |
margin-right: 8px;
|
| 319 |
width: 24px;
|
| 320 |
height: 24px;
|
| 321 |
}
|
| 322 |
-
|
| 323 |
.dropdown-content a:hover {
|
| 324 |
background-color: var(--hover-bg-color);
|
| 325 |
}
|
| 326 |
-
|
| 327 |
.dropdown-content a:hover {
|
| 328 |
background-color: var(--hover-bg-color);
|
| 329 |
}
|
| 330 |
-
|
| 331 |
.dropbtn:focus {
|
| 332 |
box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.5);
|
| 333 |
}
|
| 334 |
-
|
| 335 |
.dropbtn:focus:not(.active)::after {
|
| 336 |
content: '▲';
|
| 337 |
}
|
| 338 |
-
|
| 339 |
.dropbtn.active:focus::after {
|
| 340 |
content: '▼';
|
| 341 |
}
|
| 342 |
-
|
| 343 |
-
|
| 344 |
/* Markdown styles */
|
| 345 |
.message-container h1 {
|
| 346 |
font-size: 36px;
|
| 347 |
margin-top: 24px;
|
| 348 |
margin-bottom: 16px;
|
| 349 |
color: #fff;
|
| 350 |
-
/* Change text color to white */
|
| 351 |
}
|
| 352 |
-
|
| 353 |
.message-container h2 {
|
| 354 |
font-size: 32px;
|
| 355 |
margin-top: 20px;
|
| 356 |
margin-bottom: 12px;
|
| 357 |
color: #fff;
|
| 358 |
-
/* Change text color to white */
|
| 359 |
}
|
| 360 |
-
|
| 361 |
.message-container h3 {
|
| 362 |
font-size: 28px;
|
| 363 |
margin-top: 16px;
|
| 364 |
margin-bottom: 8px;
|
| 365 |
color: #fff;
|
| 366 |
-
/* Change text color to white */
|
| 367 |
}
|
| 368 |
-
|
| 369 |
.message-container ul,
|
| 370 |
.message-container ol {
|
| 371 |
margin-top: 12px;
|
| 372 |
margin-bottom: 12px;
|
| 373 |
padding-left: 20px;
|
| 374 |
color: #fff;
|
| 375 |
-
/* Change text color to white */
|
| 376 |
}
|
| 377 |
-
|
| 378 |
.message-container li {
|
| 379 |
margin-bottom: 6px;
|
| 380 |
}
|
| 381 |
-
|
| 382 |
.message-container pre {
|
| 383 |
background-color: #333;
|
| 384 |
-
/* Darken the background for better contrast */
|
| 385 |
padding: 16px;
|
| 386 |
border-radius: 8px;
|
| 387 |
margin-top: 12px;
|
| 388 |
margin-bottom: 12px;
|
| 389 |
overflow-x: auto;
|
| 390 |
color: #fff;
|
| 391 |
-
/* Change text color to white */
|
| 392 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 393 |
}
|
| 394 |
-
|
| 395 |
.message-container pre code {
|
| 396 |
display: block;
|
| 397 |
padding: 0;
|
| 398 |
font-size: 18px;
|
| 399 |
color: #fff;
|
| 400 |
-
/* Change text color to white */
|
| 401 |
}
|
| 402 |
-
|
| 403 |
.message-container a {
|
| 404 |
color: #007bff;
|
| 405 |
text-decoration: none;
|
| 406 |
border-bottom: 1px solid transparent;
|
| 407 |
transition: border-bottom-color 0.3s;
|
| 408 |
}
|
| 409 |
-
|
| 410 |
.message-container a:hover {
|
| 411 |
border-bottom-color: #007bff;
|
| 412 |
}
|
| 413 |
-
|
| 414 |
-
/* Support for italic and bold italic */
|
| 415 |
.message-container em {
|
| 416 |
font-style: italic;
|
| 417 |
}
|
| 418 |
-
|
| 419 |
.message-container strong {
|
| 420 |
font-weight: bold;
|
| 421 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
</style>
|
| 423 |
</head>
|
| 424 |
|
| 425 |
-
<
|
| 426 |
-
<div class="
|
| 427 |
-
|
| 428 |
-
<div class="
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
const messageElement = document.createElement('div');
|
| 470 |
-
messageElement.classList.add('message', `${role}-message`);
|
| 471 |
-
|
| 472 |
-
// Parse Markdown syntax
|
| 473 |
-
const markdownParsedMessage = parseMarkdown(message);
|
| 474 |
-
|
| 475 |
-
// Set HTML content
|
| 476 |
-
messageElement.innerHTML = markdownParsedMessage;
|
| 477 |
-
|
| 478 |
-
chatOutput.appendChild(messageElement);
|
| 479 |
-
chatOutput.scrollTop = chatOutput.scrollHeight;
|
| 480 |
-
}
|
| 481 |
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
tasklists: true,
|
| 490 |
-
literalMidWordUnderscores: true,
|
| 491 |
-
});
|
| 492 |
-
// Convert Markdown to HTML
|
| 493 |
-
return converter.makeHtml(message);
|
| 494 |
-
}
|
| 495 |
-
sendBtn.addEventListener('click', async () => {
|
| 496 |
-
const message = userInput.value.trim();
|
| 497 |
-
if (message !== '') {
|
| 498 |
-
messages.push({ "role": "user", "content": message });
|
| 499 |
-
displayMessage("> " + message, 'user');
|
| 500 |
-
const botResponse = await sendMessage();
|
| 501 |
-
messages.push({ "role": "assistant", "content": botResponse });
|
| 502 |
-
displayMessage(botResponse, 'bot');
|
| 503 |
-
userInput.value = '';
|
| 504 |
}
|
| 505 |
-
});
|
| 506 |
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
}
|
| 511 |
-
});
|
| 512 |
-
</script>
|
| 513 |
|
| 514 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
|
| 516 |
</html>
|
| 517 |
-
|
|
|
|
| 17 |
flex-direction: column;
|
| 18 |
min-height: 100vh;
|
| 19 |
}
|
|
|
|
| 20 |
.container {
|
| 21 |
flex: 1;
|
| 22 |
display: flex;
|
|
|
|
| 25 |
overflow-y: auto;
|
| 26 |
scroll-behavior: smooth;
|
| 27 |
}
|
|
|
|
| 28 |
.message-container {
|
| 29 |
display: flex;
|
| 30 |
flex-direction: column;
|
| 31 |
gap: 20px;
|
| 32 |
align-items: flex-start;
|
| 33 |
}
|
|
|
|
| 34 |
.message {
|
| 35 |
max-width: 80%;
|
| 36 |
padding: 15px 20px;
|
|
|
|
| 43 |
background: #fff;
|
| 44 |
transition: all 0.3s ease-in-out;
|
| 45 |
}
|
|
|
|
| 46 |
.message:hover {
|
| 47 |
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
|
| 48 |
transform: translateY(-3px);
|
| 49 |
}
|
|
|
|
| 50 |
.message::after {
|
| 51 |
content: '';
|
| 52 |
position: absolute;
|
|
|
|
| 58 |
opacity: 0;
|
| 59 |
transition: opacity 0.3s ease-in-out;
|
| 60 |
}
|
|
|
|
| 61 |
.message:hover::after {
|
| 62 |
opacity: 1;
|
| 63 |
}
|
|
|
|
| 64 |
.user-message {
|
| 65 |
background-color: #e0f7fa;
|
| 66 |
color: #00796b;
|
| 67 |
align-self: flex-end;
|
| 68 |
border-radius: 20px 20px 0 20px;
|
| 69 |
}
|
|
|
|
| 70 |
.bot-message {
|
| 71 |
background-color: #4c51bf;
|
| 72 |
color: #fff;
|
| 73 |
align-self: flex-start;
|
| 74 |
border-radius: 20px 20px 20px 0;
|
| 75 |
}
|
|
|
|
| 76 |
@media (max-width: 768px) {
|
| 77 |
.message {
|
| 78 |
max-width: 90%;
|
|
|
|
| 80 |
border-radius: 15px;
|
| 81 |
}
|
| 82 |
}
|
|
|
|
| 83 |
.input-container {
|
| 84 |
position: fixed;
|
| 85 |
bottom: 40px;
|
|
|
|
| 101 |
filter: blur(1px);
|
| 102 |
-webkit-filter: blur(1px);
|
| 103 |
}
|
|
|
|
| 104 |
.input-container:hover {
|
| 105 |
box-shadow: 0 100px 200px rgba(0, 0, 0, 0.5);
|
| 106 |
transform: translateY(-1px) scale(1.01);
|
|
|
|
| 108 |
filter: blur(0px);
|
| 109 |
-webkit-filter: blur(0px);
|
| 110 |
}
|
|
|
|
| 111 |
.input-container>textarea {
|
| 112 |
flex: 1;
|
| 113 |
border: none;
|
|
|
|
| 121 |
outline: none;
|
| 122 |
box-shadow: none;
|
| 123 |
resize: none;
|
|
|
|
| 124 |
}
|
|
|
|
| 125 |
.input-container>textarea:focus {
|
| 126 |
box-shadow: 0 0 0 4px rgba(0, 168, 255, 0.3);
|
| 127 |
}
|
|
|
|
| 128 |
.input-container>textarea::placeholder {
|
| 129 |
color: #666;
|
| 130 |
opacity: 1;
|
| 131 |
font-weight: 500;
|
| 132 |
}
|
|
|
|
| 133 |
.input-container::before {
|
| 134 |
content: '';
|
| 135 |
position: absolute;
|
|
|
|
| 143 |
transition: opacity 0.8s ease, transform 0.8s ease;
|
| 144 |
pointer-events: none;
|
| 145 |
}
|
|
|
|
| 146 |
.input-container:hover::before {
|
| 147 |
opacity: 0;
|
| 148 |
transform: scale(1.05);
|
| 149 |
}
|
|
|
|
| 150 |
@keyframes pulse {
|
|
|
|
| 151 |
0%,
|
| 152 |
100% {
|
| 153 |
box-shadow: 0 0 0 0 rgba(0, 168, 255, 0.5);
|
| 154 |
}
|
|
|
|
| 155 |
50% {
|
| 156 |
box-shadow: 0 0 0 6px rgba(0, 168, 255, 0);
|
| 157 |
}
|
| 158 |
}
|
|
|
|
| 159 |
.input-container:focus-within {
|
| 160 |
animation: pulse 2s infinite ease-in-out;
|
| 161 |
}
|
|
|
|
| 162 |
.input-container>textarea::-webkit-scrollbar {
|
| 163 |
width: 8px;
|
| 164 |
}
|
|
|
|
| 165 |
.input-container>textarea::-webkit-scrollbar-track {
|
| 166 |
background: #f0f0f0;
|
| 167 |
}
|
|
|
|
| 168 |
.input-container>textarea::-webkit-scrollbar-thumb {
|
| 169 |
background: #bbb;
|
| 170 |
border-radius: 8px;
|
| 171 |
border: 2px solid #f0f0f0;
|
| 172 |
}
|
|
|
|
| 173 |
.input-container>textarea::-webkit-scrollbar-thumb:hover {
|
| 174 |
background: #999;
|
| 175 |
}
|
|
|
|
| 176 |
.input-container>textarea::-webkit-scrollbar-corner {
|
| 177 |
background: transparent;
|
| 178 |
}
|
|
|
|
| 179 |
.message-input {
|
| 180 |
flex: 1;
|
| 181 |
border: none;
|
|
|
|
| 183 |
font-size: 16px;
|
| 184 |
padding: 10px;
|
| 185 |
}
|
|
|
|
| 186 |
.btn-send {
|
| 187 |
background-color: #4c51bf;
|
| 188 |
color: #fff;
|
|
|
|
| 193 |
cursor: pointer;
|
| 194 |
transition: background-color 0.3s;
|
| 195 |
}
|
|
|
|
| 196 |
.btn-send[disabled] {
|
| 197 |
background-color: #ccc;
|
| 198 |
cursor: not-allowed;
|
| 199 |
}
|
|
|
|
| 200 |
.btn-send:hover {
|
| 201 |
background-color: #3730a3;
|
| 202 |
}
|
|
|
|
| 203 |
/* Base styles */
|
| 204 |
:root {
|
| 205 |
--primary-color: #ffffff;
|
|
|
|
| 213 |
--arrow-size: 16px;
|
| 214 |
--font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 215 |
}
|
|
|
|
| 216 |
/* Resetting default styles */
|
| 217 |
* {
|
| 218 |
box-sizing: border-box;
|
|
|
|
| 220 |
padding: 0;
|
| 221 |
font-family: var(--font-family);
|
| 222 |
}
|
|
|
|
| 223 |
/* Styling the dropdown button with shadow */
|
| 224 |
.dropbtn {
|
| 225 |
background-color: var(--primary-color);
|
|
|
|
| 235 |
padding-right: 50px;
|
| 236 |
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
|
| 237 |
}
|
|
|
|
| 238 |
.dropbtn::after {
|
| 239 |
content: '▲';
|
| 240 |
font-size: var(--arrow-size);
|
|
|
|
| 244 |
transform: translateY(-50%);
|
| 245 |
transition: transform var(--transition-duration), content var(--transition-duration);
|
| 246 |
}
|
|
|
|
| 247 |
.dropbtn.active::after {
|
| 248 |
content: '▼';
|
| 249 |
transform: translateY(-50%);
|
| 250 |
}
|
|
|
|
| 251 |
.dropbtn:hover {
|
| 252 |
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.3);
|
| 253 |
}
|
|
|
|
| 254 |
.dropdown {
|
| 255 |
position: relative;
|
| 256 |
display: inline-block;
|
| 257 |
}
|
|
|
|
| 258 |
.dropdown-content {
|
| 259 |
display: none;
|
| 260 |
position: absolute;
|
|
|
|
| 266 |
overflow: hidden;
|
| 267 |
transition: all var(--transition-duration);
|
| 268 |
}
|
|
|
|
| 269 |
.dropdown-content a {
|
| 270 |
display: flex;
|
| 271 |
align-items: center;
|
|
|
|
| 274 |
color: var(--text-color);
|
| 275 |
transition: background-color var(--transition-duration);
|
| 276 |
}
|
|
|
|
| 277 |
.dropdown-content a .icon {
|
| 278 |
margin-right: 8px;
|
| 279 |
width: 24px;
|
| 280 |
height: 24px;
|
| 281 |
}
|
|
|
|
| 282 |
.dropdown-content a:hover {
|
| 283 |
background-color: var(--hover-bg-color);
|
| 284 |
}
|
|
|
|
| 285 |
.dropdown-content a:hover {
|
| 286 |
background-color: var(--hover-bg-color);
|
| 287 |
}
|
|
|
|
| 288 |
.dropbtn:focus {
|
| 289 |
box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.5);
|
| 290 |
}
|
|
|
|
| 291 |
.dropbtn:focus:not(.active)::after {
|
| 292 |
content: '▲';
|
| 293 |
}
|
|
|
|
| 294 |
.dropbtn.active:focus::after {
|
| 295 |
content: '▼';
|
| 296 |
}
|
|
|
|
|
|
|
| 297 |
/* Markdown styles */
|
| 298 |
.message-container h1 {
|
| 299 |
font-size: 36px;
|
| 300 |
margin-top: 24px;
|
| 301 |
margin-bottom: 16px;
|
| 302 |
color: #fff;
|
|
|
|
| 303 |
}
|
|
|
|
| 304 |
.message-container h2 {
|
| 305 |
font-size: 32px;
|
| 306 |
margin-top: 20px;
|
| 307 |
margin-bottom: 12px;
|
| 308 |
color: #fff;
|
|
|
|
| 309 |
}
|
|
|
|
| 310 |
.message-container h3 {
|
| 311 |
font-size: 28px;
|
| 312 |
margin-top: 16px;
|
| 313 |
margin-bottom: 8px;
|
| 314 |
color: #fff;
|
|
|
|
| 315 |
}
|
|
|
|
| 316 |
.message-container ul,
|
| 317 |
.message-container ol {
|
| 318 |
margin-top: 12px;
|
| 319 |
margin-bottom: 12px;
|
| 320 |
padding-left: 20px;
|
| 321 |
color: #fff;
|
|
|
|
| 322 |
}
|
|
|
|
| 323 |
.message-container li {
|
| 324 |
margin-bottom: 6px;
|
| 325 |
}
|
|
|
|
| 326 |
.message-container pre {
|
| 327 |
background-color: #333;
|
|
|
|
| 328 |
padding: 16px;
|
| 329 |
border-radius: 8px;
|
| 330 |
margin-top: 12px;
|
| 331 |
margin-bottom: 12px;
|
| 332 |
overflow-x: auto;
|
| 333 |
color: #fff;
|
|
|
|
| 334 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 335 |
}
|
|
|
|
| 336 |
.message-container pre code {
|
| 337 |
display: block;
|
| 338 |
padding: 0;
|
| 339 |
font-size: 18px;
|
| 340 |
color: #fff;
|
|
|
|
| 341 |
}
|
|
|
|
| 342 |
.message-container a {
|
| 343 |
color: #007bff;
|
| 344 |
text-decoration: none;
|
| 345 |
border-bottom: 1px solid transparent;
|
| 346 |
transition: border-bottom-color 0.3s;
|
| 347 |
}
|
|
|
|
| 348 |
.message-container a:hover {
|
| 349 |
border-bottom-color: #007bff;
|
| 350 |
}
|
|
|
|
|
|
|
| 351 |
.message-container em {
|
| 352 |
font-style: italic;
|
| 353 |
}
|
|
|
|
| 354 |
.message-container strong {
|
| 355 |
font-weight: bold;
|
| 356 |
}
|
| 357 |
+
.initial-message {
|
| 358 |
+
font-size: 18px;
|
| 359 |
+
color: #4c51bf;
|
| 360 |
+
margin-bottom: 20px;
|
| 361 |
+
}
|
| 362 |
</style>
|
| 363 |
</head>
|
| 364 |
|
| 365 |
+
<body>
|
| 366 |
+
<div class="container">
|
| 367 |
+
<div class="message-container">
|
| 368 |
+
<div class="initial-message">This is the real OpenAI GPT-4o</div>
|
| 369 |
+
</div>
|
| 370 |
+
</div>
|
| 371 |
+
<div class="input-container">
|
| 372 |
+
<textarea type="text" id="user-input" class="message-input" placeholder="Type your message..."></textarea>
|
| 373 |
+
<button id="send-btn" class="btn-send">
|
| 374 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 375 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 10l7-7m0 0l7 7m-7-7v18"></path>
|
| 376 |
+
</svg>
|
| 377 |
+
</button>
|
| 378 |
+
|
| 379 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/showdown.min.js"></script>
|
| 380 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/prism.min.js"></script>
|
| 381 |
+
<script>
|
| 382 |
+
const userInput = document.getElementById('user-input');
|
| 383 |
+
const sendBtn = document.getElementById('send-btn');
|
| 384 |
+
const chatOutput = document.querySelector('.message-container');
|
| 385 |
+
let messages = [];
|
| 386 |
+
|
| 387 |
+
async function sendMessage() {
|
| 388 |
+
try {
|
| 389 |
+
sendBtn.disabled = true;
|
| 390 |
+
const response = await fetch('https://gpt4.discord.rocks/ask', {
|
| 391 |
+
method: 'POST',
|
| 392 |
+
headers: {
|
| 393 |
+
'Content-Type': 'application/json'
|
| 394 |
+
},
|
| 395 |
+
body: JSON.stringify({
|
| 396 |
+
"messages": messages,
|
| 397 |
+
"model": "gpt-4o"
|
| 398 |
+
})
|
| 399 |
+
});
|
| 400 |
+
const data = await response.json();
|
| 401 |
+
sendBtn.disabled = false;
|
| 402 |
+
return data.response;
|
| 403 |
+
} catch (error) {
|
| 404 |
+
console.error('Error sending message:', error);
|
| 405 |
+
sendBtn.disabled = false;
|
| 406 |
+
return 'Error: Failed to send message.';
|
| 407 |
+
}
|
| 408 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
|
| 410 |
+
function displayMessage(message, role) {
|
| 411 |
+
const messageElement = document.createElement('div');
|
| 412 |
+
messageElement.classList.add('message', `${role}-message`);
|
| 413 |
+
const markdownParsedMessage = parseMarkdown(message);
|
| 414 |
+
messageElement.innerHTML = markdownParsedMessage;
|
| 415 |
+
chatOutput.appendChild(messageElement);
|
| 416 |
+
chatOutput.scrollTop = chatOutput.scrollHeight;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
}
|
|
|
|
| 418 |
|
| 419 |
+
function parseMarkdown(message) {
|
| 420 |
+
const converter = new showdown.Converter({
|
| 421 |
+
simplifiedAutoLink: true,
|
| 422 |
+
strikethrough: true,
|
| 423 |
+
tables: true,
|
| 424 |
+
tasklists: true,
|
| 425 |
+
literalMidWordUnderscores: true,
|
| 426 |
+
});
|
| 427 |
+
return converter.makeHtml(message);
|
| 428 |
}
|
|
|
|
|
|
|
| 429 |
|
| 430 |
+
sendBtn.addEventListener('click', async () => {
|
| 431 |
+
const message = userInput.value.trim();
|
| 432 |
+
if (message !== '') {
|
| 433 |
+
messages.push({ "role": "user", "content": message });
|
| 434 |
+
displayMessage("> " + message, 'user');
|
| 435 |
+
document.querySelector('.initial-message').style.display = 'none';
|
| 436 |
+
const botResponse = await sendMessage();
|
| 437 |
+
messages.push({ "role": "assistant", "content": botResponse });
|
| 438 |
+
displayMessage(botResponse, 'bot');
|
| 439 |
+
userInput.value = '';
|
| 440 |
+
}
|
| 441 |
+
});
|
| 442 |
+
|
| 443 |
+
userInput.addEventListener('keypress', async (event) => {
|
| 444 |
+
if (event.key === 'Enter') {
|
| 445 |
+
sendBtn.click();
|
| 446 |
+
}
|
| 447 |
+
});
|
| 448 |
+
</script>
|
| 449 |
+
</div>
|
| 450 |
+
</body>
|
| 451 |
|
| 452 |
</html>
|
|
|