document.addEventListener('DOMContentLoaded', () => { var socket = io(); document.querySelector('#send-button').onclick = () => { const message = document.querySelector('#user-input').value; const selectedModel = document.querySelector('#model-selector').value; socket.emit('send_message', {'message': message, 'model': selectedModel}); document.querySelector('#user-input').value = ''; return false; }; socket.on('receive_message', data => { const node = document.createElement("div"); const textnode = document.createTextNode(data.message); node.appendChild(textnode); document.querySelector('#chat-box').appendChild(node); }); });