summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0bf9288)
So we can actually tell who said what in the chat.
- <ul id="comments">
- </ul>
+ <dl id="comments">
+ </dl>
<p>
<form action="" id="comment-form">
<p>
<form action="" id="comment-form">
- socket.on('comment', function(msg) {
- var item = document.createElement('li');
- item.textContent = msg;
- comments.appendChild(item);
+ socket.on('comment', function(comment) {
+ const dt = document.createElement('dt');
+ const dd = document.createElement('dd');
+ dt.textContent = comment.name;
+ dd.textContent = comment.text;
+ comments.appendChild(dt);
+ comments.appendChild(dd);
});
socket.on('inform-name', (name) => {
});
socket.on('inform-name', (name) => {
});
// When any client comments, send that to all clients (including sender)
});
// When any client comments, send that to all clients (including sender)
- socket.on('comment', (comment) => {
+ socket.on('comment', (comment_text) => {
+ comment = { name: socket.request.session.name,
+ text: comment_text }
io.emit('comment', comment);
state.comments.push(comment);
});
io.emit('comment', comment);
state.comments.push(comment);
});