Skip to content

Instantly share code, notes, and snippets.

@jcrugzz
Last active December 10, 2015 13:18
Show Gist options
  • Save jcrugzz/4439437 to your computer and use it in GitHub Desktop.
Save jcrugzz/4439437 to your computer and use it in GitHub Desktop.
var hyperglue = require('hyperglue');
var html = require('./html/listElement');
module.exports = ChatList;
function ChatList (target) {
if(!(this instanceof ChatList)) return new ChatList(target);
this.target = target;
this.users = [];
this.name = 'chatList';
}
// Add event to append a new user to the chatList object
ChatList.prototype.add = Add;
function Add (user) {
var self = this;
console.log(user.name);
var div = hyperglue(html, {
'.user': user.name
});
console.log(user);
console.log(div);
self.users.push({name: user.name, element: div});
self.target.appendChild(div);
}
module.exports = [
'<div class="user"></div>'
].join('\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment