diff --git a/www/common/common-messaging.js b/www/common/common-messaging.js index 01fa6e8df..842700a3a 100644 --- a/www/common/common-messaging.js +++ b/www/common/common-messaging.js @@ -188,6 +188,18 @@ define([ UI.addToFriendList(common, $block, display, remove, curvePublic); }; + ui.createMessage = function (msg, name) { + var $msg = $('
', {'class': 'message'}) + .attr('title', msg.time ? new Date(msg.time).toLocaleString(): '?'); + + if (name) { + $('
', {'class':'sender'}).text(name).appendTo($msg); + } + + $('
', {'class':'content'}).html(parseMessage(msg.text)).appendTo($msg); + return $msg; + }; + return ui; }; @@ -599,7 +611,7 @@ define([ }); }; - Msg.init = function (common, ui) { //$listContainer, $msgContainer) { + Msg.init = function (common, ui) { // declare common variables var network = common.getNetwork(); var proxy = common.getProxy(); @@ -641,21 +653,11 @@ define([ var last = typeof(channel.lastDisplayed) === 'number'? channel.lastDisplayed: -1; for (var i = last + 1; i', {'class': 'message'}).appendTo($messages); - - // date - date = msg.time ? new Date(msg.time).toLocaleString(): '?'; - //$('
', {'class':'date'}).text(date).appendTo($msg); - $msg.attr('title', date); + name = (msg.channel !== channel.lastSender)? + getFriend(common, msg.channel).displayName: undefined; - // name - if (msg.channel !== channel.lastSender) { - name = getFriend(common, msg.channel).displayName; - $('
', {'class':'sender'}).text(name).appendTo($msg); - } + ui.createMessage(msg, name).appendTo($messages); channel.lastSender = msg.channel; - - $('
', {'class':'content'}).html(parseMessage(msg.text)).appendTo($msg); } $messages.scrollTop($messages[0].scrollHeight); channel.lastDisplayed = i-1;