Commit 4c6d6b2f authored by JC Brand's avatar JC Brand

Enable /me messages for chatrooms.

parent 3428b355
...@@ -300,7 +300,6 @@ xmppchat.ChatBoxView = Backbone.View.extend({ ...@@ -300,7 +300,6 @@ xmppchat.ChatBoxView = Backbone.View.extend({
if(ev.keyCode == 13) { if(ev.keyCode == 13) {
message = $textarea.val(); message = $textarea.val();
message = message.replace(/^\s+|\s+jQuery/g,"");
$textarea.val('').focus(); $textarea.val('').focus();
if (message !== '') { if (message !== '') {
this.sendMessage(message); this.sendMessage(message);
...@@ -435,7 +434,7 @@ xmppchat.ChatBoxView = Backbone.View.extend({ ...@@ -435,7 +434,7 @@ xmppchat.ChatBoxView = Backbone.View.extend({
xmppchat.ContactsPanel = Backbone.View.extend({ xmppchat.ContactsPanel = Backbone.View.extend({
el: '#users', el: '#users',
events: { events: {
'click div.add-xmpp-contact': 'toggleContactForm', 'click a.add-xmpp-contact': 'toggleContactForm',
'submit form.search-xmpp-contact': 'searchContacts', 'submit form.search-xmpp-contact': 'searchContacts',
'click a.subscribe-to-user': 'subscribeToContact' 'click a.subscribe-to-user': 'subscribeToContact'
}, },
...@@ -718,14 +717,28 @@ xmppchat.ChatRoomView = xmppchat.ChatBoxView.extend({ ...@@ -718,14 +717,28 @@ xmppchat.ChatRoomView = xmppchat.ChatBoxView.extend({
this.appendMessage(body); this.appendMessage(body);
} else { } else {
$chat_content.find('div.chat-event').remove(); $chat_content.find('div.chat-event').remove();
$chat_content.append(
this.message_template({ match = body.match(/^\/(.*?)(?: (.*))?$/);
'sender': 'them', if ((match) && (match[1] === 'me')) {
'time': (new Date()).toLocaleTimeString().substring(0,5), body = body.replace(/^\/me/, '*'+sender);
'message': body.replace(/<br \/>/g, ""), $chat_content.append(
'username': sender, this.action_template({
'extra_classes': ($(message).find('delay').length > 0) && 'delayed' || '' 'sender': 'room',
})); 'time': (new Date()).toLocaleTimeString().substring(0,5),
'message': body,
'username': sender,
'extra_classes': ($(message).find('delay').length > 0) && 'delayed' || ''
}));
} else {
$chat_content.append(
this.message_template({
'sender': 'room',
'time': (new Date()).toLocaleTimeString().substring(0,5),
'message': body,
'username': sender,
'extra_classes': ($(message).find('delay').length > 0) && 'delayed' || ''
}));
}
$chat_content.scrollTop($chat_content[0].scrollHeight); $chat_content.scrollTop($chat_content[0].scrollHeight);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment