Tagit bort kod som inte behövs längre
This commit is contained in:
@@ -3,17 +3,6 @@
|
|||||||
const chatbox = document.getElementById('chatbox');
|
const chatbox = document.getElementById('chatbox');
|
||||||
const userInput = document.getElementById('userInput');
|
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
|
// Define a function to send the user's message to the AI
|
||||||
function sendMessage() {
|
function sendMessage() {
|
||||||
// Get the user's input message and trim any whitespace
|
// Get the user's input message and trim any whitespace
|
||||||
@@ -21,8 +10,7 @@ function sendMessage() {
|
|||||||
|
|
||||||
// Check if the message is not empty
|
// Check if the message is not empty
|
||||||
if (query !== '') {
|
if (query !== '') {
|
||||||
// Send a POST request to the /api/chat endpoint with the message
|
|
||||||
// fetch('http://localhost:5005/api/chat', {
|
|
||||||
fetch(`${apiEndpoint}`, {
|
fetch(`${apiEndpoint}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
@@ -59,23 +47,4 @@ function renderMessage(text, className) {
|
|||||||
|
|
||||||
// Append the message element to the chatbox
|
// Append the message element to the chatbox
|
||||||
chatbox.appendChild(messageElement);
|
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);
|
|
||||||
Reference in New Issue
Block a user