Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
clusterzx committed Jan 16, 2025
2 parents 34c25d6 + 89a4ca1 commit ac44c4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [clusterzx]
15 changes: 10 additions & 5 deletions public/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,14 @@ document.getElementById('documentSelect').addEventListener('change', function()
}
});

document.getElementById('messageForm').addEventListener('submit', async function(e) {
e.preventDefault();

document.getElementById('messageInput').addEventListener('keydown', async (e) => {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
await submitForm();
}
})

async function submitForm(){
const messageInput = document.getElementById('messageInput');
const message = messageInput.value.trim();

Expand All @@ -214,7 +219,7 @@ document.getElementById('messageForm').addEventListener('submit', async function
if (response) {
addMessage(response, false);
}
} catch (error) {
} catch {
showError('Failed to send message');
}
});
}
4 changes: 2 additions & 2 deletions views/chat.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</div>

<!-- Message Input -->
<form id="messageForm" class="message-form hidden">
<div id="messageForm" class="message-form hidden">
<input type="hidden" id="documentId" name="documentId" value="">
<textarea
id="messageInput"
Expand All @@ -51,7 +51,7 @@
<button type="submit" class="send-button">
Send
</button>
</form>
</div>
</div>
</div>

Expand Down

0 comments on commit ac44c4e

Please sign in to comment.