dynamically create rooms chatboxes

This commit is contained in:
2025-03-04 15:10:07 +01:00
parent 4d68e7a9f7
commit e95c9eda0f
8 changed files with 85 additions and 19 deletions

View File

@@ -1,11 +1,11 @@
const socket = io();
const form = document.getElementById('form');
const input = document.getElementById('input');
form.addEventListener('submit', function(e) {
e.preventDefault();
if (input.value) {
socket.emit('chat message', input.value);
input.value = '';
}
});
export function create_listener(form, input) {
form.addEventListener('submit', function(e) {
e.preventDefault();
if (input.value) {
socket.emit('chat message', input.value, form.id);
input.value = '';
}
});
}