Tagit bort kod som inte behövs längre

This commit is contained in:
Joakim Persson
2024-07-27 22:46:55 +02:00
parent d1b0554748
commit 5245e53954
+2 -33
View File
@@ -3,17 +3,6 @@
const chatbox = document.getElementById('chatbox');
const userInput = document.getElementById('userInput');
// Get API endpoint for chat from environment variable
// Handle resize events
window.addEventListener('resize', () => {
chatbox.style.height = 'auto';
});
// ... other code for sending messages ...
// Define a function to send the user's message to the AI
function sendMessage() {
// Get the user's input message and trim any whitespace
@@ -21,8 +10,7 @@ function sendMessage() {
// Check if the message is not empty
if (query !== '') {
// Send a POST request to the /api/chat endpoint with the message
// fetch('http://localhost:5005/api/chat', {
fetch(`${apiEndpoint}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
@@ -59,23 +47,4 @@ function renderMessage(text, className) {
// Append the message element to the chatbox
chatbox.appendChild(messageElement);
}
function handleIframeLoad() {
const clientFrame = document.getElementById('client-frame');
if (clientFrame) { // Check if the iframe exists
const apiEndpoint = clientFrame.getAttribute('data-api-endpoint') || clientFrame.srcdoc.split('?')[1].split('=')[1];
console.log("The API Endpoint is:", apiEndpoint);
// Now you can use this 'apiEndpoint' for communication
} else {
setTimeout(handleIframeLoad, 200); // Retry in a short while if iframe not found yet
console.log("The iframe with id client-frame not found yet");
}
}
window.addEventListener('load', handleIframeLoad);
}