lib/jschat/http/public/javascripts/app/protocol/display.js in jschat-0.1.5 vs lib/jschat/http/public/javascripts/app/protocol/display.js in jschat-0.2.0

- old
+ new

@@ -11,24 +11,30 @@ $$('#messages li').last().select('img').each(function(element) { element.observe('load', this.scrollMessagesToTop); }.bind(this)); }, - message: function(message) { + message: function(message, time) { var name = $('name').innerHTML; var user_class = name == message['user'] ? 'user active' : 'user'; var text = '<span class="\#{user_class}">\#{user}</span> <span class="\#{message_class}">\#{message}</span>'; if (message['message'].match(new RegExp(name, 'i')) && name != message['user']) { user_class = 'user mentioned'; } Display.clearIdleState(message['user']); - text = text.interpolate({ user_class: user_class, room: message['room'], user: TextHelper.truncateName(message['user']), message: TextHelper.decorateMessage(message['message']), message_class: 'message' }); - this.add_message(text, 'message', message['time']); + text = text.interpolate({ + user_class: user_class, + room: message['room'], + user: TextHelper.truncateName(message['user']), + message: TextHelper.decorateMessage(message['message']), + message_class: 'message' + }); + this.add_message(text, 'message', time); this.addImageOnLoads(); if (this.show_unread) { this.unread++; document.title = 'JsChat: (' + this.unread + ') new messages'; @@ -108,13 +114,13 @@ join: function(join) { $('room-name').innerHTML = TextHelper.truncateRoomName(join['room']); $('room-name').title = PageHelper.currentRoom(); }, - join_notice: function(join) { + join_notice: function(join, time) { this.add_user(join['user']); - this.add_message(join['user'] + ' has joined the room', 'server', join['time']); + this.add_message(join['user'] + ' has joined the room', 'server', time); }, add_user: function(name) { if (!this.ignore_notices) { $('names').insert({ bottom: '<li>' + TextHelper.truncateName(name) + '</li>' }); @@ -125,17 +131,17 @@ if (!this.ignore_notices) { $$('#names li').each(function(element) { if (element.innerHTML == name) element.remove(); }); } }, - part_notice: function(part) { + part_notice: function(part, time) { this.remove_user(part['user']); - this.add_message(part['user'] + ' has left the room', 'server', part['time']); + this.add_message(part['user'] + ' has left the room', 'server', time); }, - quit_notice: function(quit) { + quit_notice: function(quit, time) { this.remove_user(quit['user']); - this.add_message(quit['user'] + ' has quit', 'server', quit['time']); + this.add_message(quit['user'] + ' has quit', 'server', time); }, notice: function(notice) { this.add_message(notice, 'server'); },