From 5245e53954ea5849b70ded4e9ced0e8405b1c710 Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Sat, 27 Jul 2024 22:46:55 +0200 Subject: [PATCH] =?UTF-8?q?Tagit=20bort=20kod=20som=20inte=20beh=C3=B6vs?= =?UTF-8?q?=20l=C3=A4ngre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smartassist/src/static/js/frontend.js | 35 ++------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/smartassist/src/static/js/frontend.js b/smartassist/src/static/js/frontend.js index ec029ca..15cc91c 100644 --- a/smartassist/src/static/js/frontend.js +++ b/smartassist/src/static/js/frontend.js @@ -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); +} \ No newline at end of file