fix
This commit is contained in:
parent
fd4adcc136
commit
0dd4a4c696
@ -4,7 +4,7 @@
|
||||
<div class="chat-input-container mb-5">
|
||||
<div class="textarea-wrapper">
|
||||
<textarea {% if not IsLogin or not HaveKey %}disabled{% endif %} class="textarea"
|
||||
placeholder="Type your message here..." name="message" oninput="toggleSendButton(this)"
|
||||
placeholder="Type your message here..." name="message" oninput="toggleSendButton()"
|
||||
id="chat-input-textarea"></textarea>
|
||||
<div class="button-group">
|
||||
<hx hx-get="/loadSettings" hx-trigger="load" hx-swap="outerHTML" hx-target="this"></hx>
|
||||
@ -37,18 +37,19 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const textarea = document.querySelector('.textarea');
|
||||
const textarea = document.querySelector('#chat-input-textarea');
|
||||
textarea.addEventListener('keydown', handleTextareaKeydown);
|
||||
|
||||
function toggleSendButton(textarea) {
|
||||
var sendButton = document.getElementById('chat-input-send-btn');
|
||||
sendButton.disabled = textarea.value.trim() === '';
|
||||
function toggleSendButton() {
|
||||
const sendButton = document.getElementById('chat-input-send-btn');
|
||||
const selectedLLMIds = JSON.parse(getSelectedModelsIDs());
|
||||
sendButton.disabled = textarea.value.trim() === '' || selectedLLMIds.length === 0;
|
||||
}
|
||||
|
||||
function clearTextArea() {
|
||||
setTimeout(function () {
|
||||
textarea.value = '';
|
||||
toggleSendButton(textarea);
|
||||
toggleSendButton();
|
||||
}, 200);
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
element.classList.remove('unselected');
|
||||
element.classList.add('selected');
|
||||
}
|
||||
toggleSendButton();
|
||||
}
|
||||
|
||||
function getSelectedModelsIDs() {
|
||||
@ -42,7 +43,7 @@
|
||||
for (var i = 0; i < selectedModels.length; i++) {
|
||||
selectedModelsIDs.push(selectedModels[i].getAttribute('value'));
|
||||
}
|
||||
return JSON.stringify(selectedModelsIDs);
|
||||
return selectedModelsIDs.length > 0 ? JSON.stringify(selectedModelsIDs) : '[]';
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -51,11 +52,12 @@
|
||||
border: 2px solid #3273dc;
|
||||
/* Bulma's primary color */
|
||||
border-radius: 4px;
|
||||
padding: 2px;
|
||||
padding: 1px;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
.unselected {
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
padding: 3px;
|
||||
}
|
||||
</style>
|
Loading…
x
Reference in New Issue
Block a user