From 5d602caa7e96213a0785eddd5f61b014c4d36b81 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Mon, 9 Jul 2012 18:47:50 +0200 Subject: [PATCH] Create models, views and collections for the chat boxes. --- chat.js | 245 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 161 insertions(+), 84 deletions(-) diff --git a/chat.js b/chat.js index 0e672a3fd..282fa6ec5 100644 --- a/chat.js +++ b/chat.js @@ -190,14 +190,73 @@ var xmppchat = (function (jarnxmpp, $, console) { xmppchat.ChatBox = Backbone.Model.extend({ + + hash: function (str) { + var shaobj = new jsSHA(str); + return shaobj.getHash("HEX"); + }, + + initialize: function () { + this.set({ + 'user_id' : Strophe.getNodeFromJid(this.get('jid')), + 'chat_id' : this.hash(this.get('jid')) + }); + } + +}); + +xmppchat.ChatBoxView = Backbone.View.extend({ + + initialize: function (){ + this.el = this.make('div', {'class': 'chatbox'}); + $('body').append($(this.el).hide()); + }, + + template: _.template('
' + + '
<%= user_id %>
' + + 'X' + + '
' + + '
' + + '
' + + '
' + + '