move chat input handling to js, clean up deprecated symbols, fix chat input height scaling

This commit is contained in:
Radon 2025-08-29 14:22:00 -05:00
parent 39cd140243
commit 19d7f21bd0
2 changed files with 14 additions and 17 deletions

View File

@ -1901,9 +1901,21 @@ class EventHandlers {
}
});
chatInput.addEventListener('input', function() {
chatInput.addEventListener('input', function(e) {
sendBtn.disabled = this.value.trim().length === 0;
const textarea = e.target;
textarea.style.height = 'auto';
textarea.style.height = Math.min(textarea.scrollHeight, window.innerHeight * 0.5) + 'px';
document.getElementById('send-btn').disabled = textarea.value.trim().length === 0;
});
chatInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
event.preventDefault();
EventHandlers.sendChatMessage();
}
})
EventHandlers.setupGlobalEventListeners();
}
static setupGlobalEventListeners() {
@ -1939,18 +1951,7 @@ class EventHandlers {
}
});
}
static handleChatInput(event) {
const textarea = event.target;
textarea.style.height = 'auto';
textarea.style.height = Math.min(textarea.scrollHeight, 120) + 'px';
document.getElementById('send-btn').disabled = textarea.value.trim().length === 0;
}
static handleChatKeyPress(event) {
if (event.key === 'Enter' && !event.shiftKey) {
event.preventDefault();
EventHandlers.sendChatMessage();
}
}
static sendChatMessage() {
const chatInput = document.getElementById('chat-input');
const message = chatInput.value.trim();
@ -2106,8 +2107,6 @@ window.resetUserVolume = ModalManager.resetUserVolume;
window.updateMicVolume = VoiceControls.updateMicVolume;
window.updateHeadphoneVolume = VoiceControls.updateHeadphoneVolume;
window.resetAllVolumes = VoiceControls.resetAllVolumes;
window.handleChatInput = EventHandlers.handleChatInput;
window.handleChatKeyPress = EventHandlers.handleChatKeyPress;
window.sendChatMessage = EventHandlers.sendChatMessage;
window.requestMicrophonePermission = AudioManager.requestMicrophonePermission;
window.toggleEmojiPicker = UIManager.toggleEmojiPicker;

View File

@ -102,8 +102,6 @@
id="chat-input"
placeholder="Type a message..."
rows="1"
onkeypress="handleChatKeyPress(event)"
oninput="handleChatInput(event)"
></textarea>
<label for="chat-input"></label>
<button id="scroll-btn" onclick="scrollChatToBottom()" style="display: none;"></button>