Download script.js from druma-davi/chatty-mcchatface-clone: direct link, hf CLI and curl.
- Browser
- Download file 970 Bytes
-
https://huggingface.co/spaces/druma-davi/chatty-mcchatface-clone/resolve/main/script.js
- Command line
-
hf download hf://spaces/druma-davi/chatty-mcchatface-clone/script.js
-
curl -L -o script.js https://huggingface.co/spaces/druma-davi/chatty-mcchatface-clone/resolve/main/script.js
970 Bytes
| 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(); | |
| } | |
| }); | |
| }); |