Update index.html
Browse files- index.html +87 -87
index.html
CHANGED
|
@@ -300,18 +300,21 @@
|
|
| 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 {
|
|
@@ -319,18 +322,21 @@
|
|
| 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 {
|
|
@@ -338,6 +344,7 @@
|
|
| 338 |
padding: 0;
|
| 339 |
font-size: 18px;
|
| 340 |
color: #fff;
|
|
|
|
| 341 |
}
|
| 342 |
.message-container a {
|
| 343 |
color: #007bff;
|
|
@@ -348,105 +355,98 @@
|
|
| 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 |
-
<
|
| 366 |
-
<div class="container">
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 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 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
}
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
const markdownParsedMessage = parseMarkdown(message);
|
| 414 |
-
messageElement.innerHTML = markdownParsedMessage;
|
| 415 |
-
chatOutput.appendChild(messageElement);
|
| 416 |
-
chatOutput.scrollTop = chatOutput.scrollHeight;
|
| 417 |
}
|
|
|
|
|
|
|
| 418 |
|
| 419 |
-
|
| 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>
|
|
|
|
| 300 |
margin-top: 24px;
|
| 301 |
margin-bottom: 16px;
|
| 302 |
color: #fff;
|
| 303 |
+
/* Change text color to white */
|
| 304 |
}
|
| 305 |
.message-container h2 {
|
| 306 |
font-size: 32px;
|
| 307 |
margin-top: 20px;
|
| 308 |
margin-bottom: 12px;
|
| 309 |
color: #fff;
|
| 310 |
+
/* Change text color to white */
|
| 311 |
}
|
| 312 |
.message-container h3 {
|
| 313 |
font-size: 28px;
|
| 314 |
margin-top: 16px;
|
| 315 |
margin-bottom: 8px;
|
| 316 |
color: #fff;
|
| 317 |
+
/* Change text color to white */
|
| 318 |
}
|
| 319 |
.message-container ul,
|
| 320 |
.message-container ol {
|
|
|
|
| 322 |
margin-bottom: 12px;
|
| 323 |
padding-left: 20px;
|
| 324 |
color: #fff;
|
| 325 |
+
/* Change text color to white */
|
| 326 |
}
|
| 327 |
.message-container li {
|
| 328 |
margin-bottom: 6px;
|
| 329 |
}
|
| 330 |
.message-container pre {
|
| 331 |
background-color: #333;
|
| 332 |
+
/* Darken the background for better contrast */
|
| 333 |
padding: 16px;
|
| 334 |
border-radius: 8px;
|
| 335 |
margin-top: 12px;
|
| 336 |
margin-bottom: 12px;
|
| 337 |
overflow-x: auto;
|
| 338 |
color: #fff;
|
| 339 |
+
/* Change text color to white */
|
| 340 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 341 |
}
|
| 342 |
.message-container pre code {
|
|
|
|
| 344 |
padding: 0;
|
| 345 |
font-size: 18px;
|
| 346 |
color: #fff;
|
| 347 |
+
/* Change text color to white */
|
| 348 |
}
|
| 349 |
.message-container a {
|
| 350 |
color: #007bff;
|
|
|
|
| 355 |
.message-container a:hover {
|
| 356 |
border-bottom-color: #007bff;
|
| 357 |
}
|
| 358 |
+
|
| 359 |
+
/* Support for italic and bold italic */
|
| 360 |
.message-container em {
|
| 361 |
font-style: italic;
|
| 362 |
}
|
| 363 |
.message-container strong {
|
| 364 |
font-weight: bold;
|
| 365 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
</style>
|
| 367 |
</head>
|
| 368 |
|
| 369 |
+
<div class="container">
|
| 370 |
+
<div class="message-container"></div>
|
| 371 |
+
</div>
|
| 372 |
+
<div class="input-container">
|
| 373 |
+
<textarea type="text" id="user-input" class="message-input" placeholder="Type your message..."></textarea>
|
| 374 |
+
<button id="send-btn" class="btn-send">
|
| 375 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 376 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 10l7-7m0 0l7 7m-7-7v18"></path>
|
| 377 |
+
</svg>
|
| 378 |
+
</button>
|
|
|
|
|
|
|
|
|
|
| 379 |
|
| 380 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/showdown.min.js"></script>
|
| 381 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/prism.min.js"></script>
|
| 382 |
+
<script>
|
| 383 |
+
const userInput = document.getElementById('user-input');
|
| 384 |
+
const sendBtn = document.getElementById('send-btn');
|
| 385 |
+
const chatOutput = document.querySelector('.message-container');
|
| 386 |
+
let messages = [];
|
| 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 |
+
function displayMessage(message, role) {
|
| 410 |
+
const messageElement = document.createElement('div');
|
| 411 |
+
messageElement.classList.add('message', `${role}-message`);
|
| 412 |
+
// Parse Markdown syntax
|
| 413 |
+
const markdownParsedMessage = parseMarkdown(message);
|
| 414 |
+
// Set HTML content
|
| 415 |
+
messageElement.innerHTML = markdownParsedMessage;
|
| 416 |
+
chatOutput.appendChild(messageElement);
|
| 417 |
+
chatOutput.scrollTop = chatOutput.scrollHeight;
|
| 418 |
+
}
|
| 419 |
+
function parseMarkdown(message) {
|
| 420 |
+
// Initialize Showdown converter
|
| 421 |
+
const converter = new showdown.Converter({
|
| 422 |
+
// Enable all Markdown extensions
|
| 423 |
+
simplifiedAutoLink: true,
|
| 424 |
+
strikethrough: true,
|
| 425 |
+
tables: true,
|
| 426 |
+
tasklists: true,
|
| 427 |
+
literalMidWordUnderscores: true,
|
| 428 |
+
});
|
| 429 |
+
// Convert Markdown to HTML
|
| 430 |
+
return converter.makeHtml(message);
|
| 431 |
+
}
|
| 432 |
+
sendBtn.addEventListener('click', async () => {
|
| 433 |
+
const message = userInput.value.trim();
|
| 434 |
+
if (message !== '') {
|
| 435 |
+
messages.push({ "role": "user", "content": message });
|
| 436 |
+
displayMessage("> " + message, 'user');
|
| 437 |
+
const botResponse = await sendMessage();
|
| 438 |
+
messages.push({ "role": "assistant", "content": botResponse });
|
| 439 |
+
displayMessage(botResponse, 'bot');
|
| 440 |
+
userInput.value = '';
|
| 441 |
}
|
| 442 |
+
});
|
| 443 |
+
userInput.addEventListener('keypress', async (event) => {
|
| 444 |
+
if (event.key === 'Enter') {
|
| 445 |
+
sendBtn.click();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 446 |
}
|
| 447 |
+
});
|
| 448 |
+
</script>
|
| 449 |
|
| 450 |
+
</body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
|
| 452 |
</html>
|