File size: 970 Bytes
819efbb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
document.addEventListener('DOMContentLoaded', function() {
// Auto-resize textarea
const textarea = document.querySelector('textarea');
textarea.addEventListener('input', function() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
// Simulate sending a message
const sendButton = document.querySelector('button[aria-label="Send message"]');
sendButton.addEventListener('click', function() {
const message = textarea.value.trim();
if (message) {
// In a real app, you would send this to your backend
console.log('Message sent:', message);
textarea.value = '';
textarea.style.height = '60px';
}
});
// Handle Enter key press
textarea.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
sendButton.click();
}
});
}); |