diff --git a/uncloseai.js b/uncloseai.js index 00a788c..e255ad7 100644 --- a/uncloseai.js +++ b/uncloseai.js @@ -1118,42 +1118,38 @@ async function handleUploadFromElement(button) { // Initialize the legacy chat interface (for backward compatibility) function initializeChatInterface() { - try { - // Only initialize if there are legacy elements (chat-container, user-input, etc.) - const legacyElements = document.querySelector('#chat-container, #user-input, #chat-box'); - if (!legacyElements) return; - - const pageContent = extractWebpageContent(); - chatHistory.push({ - role: "system", - content: `Here's the content of the webpage: ${pageContent}` - }); + // Only initialize if there are legacy elements (chat-container, user-input, etc.) + const legacyElements = document.querySelector('#chat-container, #user-input, #chat-box'); + if (!legacyElements) return; + + const pageContent = extractWebpageContent(); + chatHistory.push({ + role: "system", + content: `Here's the content of the webpage: ${pageContent}` + }); - marked.setOptions({ - highlight: function(code, lang) { - const language = hljs.getLanguage(lang) ? lang : 'plaintext'; - return hljs.highlight(code, { language }).value; - } - }); - - // Add the Read Page button - addReadPageButton(); + marked.setOptions({ + highlight: function(code, lang) { + const language = hljs.getLanguage(lang) ? lang : 'plaintext'; + return hljs.highlight(code, { language }).value; + } + }); + + // Add the Read Page button + addReadPageButton(); - // Add the File Upload button and picker - addFileUploadButton(); - } catch (error) { - console.error('Error in initializeChatInterface:', error); - } + // Add the File Upload button and picker + addFileUploadButton(); + + // Event listeners + document.getElementById("user-input").addEventListener("keydown", function(event) { + if (event.key === "Enter" && !event.shiftKey) { + event.preventDefault(); + handleUserInput(); + } + }); } -// Event listeners -document.getElementById("user-input").addEventListener("keydown", function(event) { - if (event.key === "Enter" && !event.shiftKey) { - event.preventDefault(); - handleUserInput(); - } -}); - // Function to create floating AI button function createFloatingAIButton() {