Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions chat-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,13 @@ document.addEventListener("DOMContentLoaded", () => {
});
sendButton.addEventListener("click", handleSendMessage);

// Send on Enter (newline with Shift+Enter)
// Send on Enter, allow newline with Shift+Enter
chatInput.addEventListener('keydown', (e) => {
if (e.key === 'Enter' && !e.shiftKey) {
if (e.key === 'Enter') {
if (e.shiftKey) return; // allow newline
e.preventDefault();
handleSendMessage();
// Trigger the same action as the send button
sendButton.click();
}
});
sendButton.disabled = chatInput.value.trim() === "";
Expand Down
39 changes: 24 additions & 15 deletions simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,30 @@ document.addEventListener("DOMContentLoaded", () => {
simpleSendBtn.addEventListener("click", () => {
const message = simpleInput.value.trim();
if (message === "") return;
const currentSession = Storage.getCurrentSession();
currentSession.messages.push({ role: "user", content: message });
Storage.updateSessionMessages(currentSession.id, currentSession.messages);
appendSimpleMessage("user", message, currentSession.messages.length - 1);
simpleInput.value = "";
simpleSendBtn.disabled = true;
window.sendToPollinations(() => {
const updatedSession = Storage.getCurrentSession();
const lastMessage = updatedSession.messages[updatedSession.messages.length - 1];
if (lastMessage.role === "ai") {
appendSimpleMessage("ai", lastMessage.content, updatedSession.messages.length - 1);
}
simpleInput.focus();
});
});
const currentSession = Storage.getCurrentSession();
currentSession.messages.push({ role: "user", content: message });
Storage.updateSessionMessages(currentSession.id, currentSession.messages);
appendSimpleMessage("user", message, currentSession.messages.length - 1);
simpleInput.value = "";
simpleSendBtn.disabled = true;
window.sendToPollinations(() => {
const updatedSession = Storage.getCurrentSession();
const lastMessage = updatedSession.messages[updatedSession.messages.length - 1];
if (lastMessage.role === "ai") {
appendSimpleMessage("ai", lastMessage.content, updatedSession.messages.length - 1);
}
simpleInput.focus();
});
});

// Send on Enter, allow newline with Shift+Enter
simpleInput.addEventListener('keydown', (e) => {
if (e.key === 'Enter') {
if (e.shiftKey) return; // allow newline
e.preventDefault();
simpleSendBtn.click();
}
});

function appendSimpleMessage(role, content, index) {
const container = document.createElement("div");
Expand Down