Commit 069310c6 authored by JC Brand's avatar JC Brand

Add support for showing firstnames instead of usernames.

parent 194e9688
...@@ -14,7 +14,20 @@ ...@@ -14,7 +14,20 @@
(function (root, factory) { (function (root, factory) {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
define([ define([
'burry.js/burry' 'Libraries/burry.js/burry',
"Libraries/jquery.gritter.min",
"Libraries/jquery.cookie",
"Libraries/jquery.ba-dotimeout.min",
"Libraries/underscore",
"Libraries/underscore.string/lib/underscore.string",
"Libraries/backbone",
"Libraries/strophe",
"Libraries/strophe.muc",
"Libraries/strophe.roster",
"Libraries/diff_match_patch",
"Libraries/jarnxmpp.core.handlers",
"Libraries/jarnxmpp.collaboration.protocol",
"Libraries/jarnxmpp.collaboration.collaborate"
], function (Burry) { ], function (Burry) {
var store = new Burry.Store('collective.xmpp.chat'); var store = new Burry.Store('collective.xmpp.chat');
// Use Mustache style syntax for variable interpolation // Use Mustache style syntax for variable interpolation
...@@ -22,7 +35,6 @@ ...@@ -22,7 +35,6 @@
evaluate : /\{\[([\s\S]+?)\]\}/g, evaluate : /\{\[([\s\S]+?)\]\}/g,
interpolate : /\{\{([\s\S]+?)\}\}/g interpolate : /\{\{([\s\S]+?)\}\}/g
}; };
_.str = require('underscore.string');
return factory(jarnxmpp, jQuery, store, _, console); return factory(jarnxmpp, jQuery, store, _, console);
} }
); );
...@@ -223,25 +235,14 @@ ...@@ -223,25 +235,14 @@
} else { } else {
time = (new Date()).toLocaleTimeString().substring(0,5); time = (new Date()).toLocaleTimeString().substring(0,5);
} }
match = body.match(/^\/(.*?)(?: (.*))?$/);
if ((match) && (match[1] === 'me')) {
$chat_content.append(this.action_template({
'sender': 'them',
'time': time,
'message': body.replace(/^\/me/, '*'+user_id).replace(/<br \/>/g, ""),
'username': xmppchat.username,
'extra_classes': delayed && 'delayed' || ''
}));
} else {
$chat_content.append( $chat_content.append(
this.message_template({ this.message_template({
'sender': 'them', 'sender': 'them',
'time': time, 'time': time,
'message': body.replace(/<br \/>/g, ""), 'message': body.replace(/<br \/>/g, ""),
'username': fullname, 'username': fullname.split(' ')[0],
'extra_classes': delayed && 'delayed' || '' 'extra_classes': delayed && 'delayed' || ''
})); }));
}
$chat_content.scrollTop($chat_content[0].scrollHeight); $chat_content.scrollTop($chat_content[0].scrollHeight);
} }
}, },
...@@ -257,16 +258,6 @@ ...@@ -257,16 +258,6 @@
msg = String(msg).replace(/(.*?\s.*?\s)/, ''); msg = String(msg).replace(/(.*?\s.*?\s)/, '');
match = msg.match(/^\/(.*?)(?: (.*))?$/); match = msg.match(/^\/(.*?)(?: (.*))?$/);
if (msg_array[1] == 'to') { if (msg_array[1] == 'to') {
if ((match) && (match[1] === 'me')) {
$content.append(
this.action_template({
'sender': 'me',
'time': new Date(Date.parse(date)).toLocaleTimeString().substring(0,5),
'message': msg.replace(/^\/me/, '*'+xmppchat.username),
'username': xmppchat.username,
'extra_classes': 'delayed'
}));
} else {
$content.append( $content.append(
this.message_template({ this.message_template({
'sender': 'me', 'sender': 'me',
...@@ -275,29 +266,17 @@ ...@@ -275,29 +266,17 @@
'username': 'me', 'username': 'me',
'extra_classes': 'delayed' 'extra_classes': 'delayed'
})); }));
}
} else {
if ((match) && (match[1] === 'me')) {
$content.append(
this.action_template({
'sender': 'them',
'time': new Date(Date.parse(date)).toLocaleTimeString().substring(0,5),
'message': msg.replace(/^\/me/, '*'+this.model.get('user_id')),
'username': this.model.get('fullname'),
'extra_classes': 'delayed'
}));
} else { } else {
$content.append( $content.append(
this.message_template({ this.message_template({
'sender': 'them', 'sender': 'them',
'time': new Date(Date.parse(date)).toLocaleTimeString().substring(0,5), 'time': new Date(Date.parse(date)).toLocaleTimeString().substring(0,5),
'message': msg, 'message': msg,
'username': this.model.get('fullname'), 'username': this.model.get('fullname').split(' ')[0],
'extra_classes': 'delayed' 'extra_classes': 'delayed'
})); }));
} }
} }
}
}, this)); }, this));
}, },
...@@ -554,7 +533,7 @@ ...@@ -554,7 +533,7 @@
return; return;
} }
} }
xmppchat.chatboxesview.openChat(jid); xmppchat.chatboxesview.openChat(jid, xmppchat.fullname);
} }
}); });
...@@ -591,12 +570,11 @@ ...@@ -591,12 +570,11 @@
}); });
xmppchat.ChatRoom = xmppchat.ChatBox.extend({ xmppchat.ChatRoom = xmppchat.ChatBox.extend({
initialize: function (jid) { initialize: function (jid, nick) {
var nick = Strophe.getNodeFromJid(xmppchat.connection.jid);
this.set({ this.set({
'id': jid, 'id': jid,
'name': Strophe.unescapeNode(Strophe.getNodeFromJid(jid)), 'name': Strophe.unescapeNode(Strophe.getNodeFromJid(jid)),
'nick': Strophe.unescapeNode(Strophe.getNodeFromJid(xmppchat.connection.jid)), 'nick': nick,
'jid': jid, 'jid': jid,
'box_id' : hex_sha1(jid) 'box_id' : hex_sha1(jid)
}, {'silent': true}); }, {'silent': true});
...@@ -845,7 +823,7 @@ ...@@ -845,7 +823,7 @@
}); });
} else { } else {
if (this.isChatRoom(jid)) { if (this.isChatRoom(jid)) {
box = new xmppchat.ChatRoom(jid); box = new xmppchat.ChatRoom(jid, xmppchat.fullname.split(' ')[0])
view = new xmppchat.ChatRoomView({ view = new xmppchat.ChatRoomView({
'model': box 'model': box
}); });
...@@ -1052,7 +1030,8 @@ ...@@ -1052,7 +1030,8 @@
this.$el.delegate('a.remove-xmpp-contact','click', function (ev) { this.$el.delegate('a.remove-xmpp-contact','click', function (ev) {
ev.preventDefault(); ev.preventDefault();
that.removeContact(); that.removeContact();
}); return this; });
return this;
}, },
initialize: function () { initialize: function () {
...@@ -1498,7 +1477,7 @@ ...@@ -1498,7 +1477,7 @@
$toggle.unbind('click'); $toggle.unbind('click');
this.username = chatdata.attr('username'); this.username = chatdata.attr('username');
this.fullname = chatdata.attr('username'); this.fullname = chatdata.attr('fullname');
this.auto_subscribe = chatdata.attr('auto_subscribe'); this.auto_subscribe = chatdata.attr('auto_subscribe');
$(document).unbind('jarnxmpp.connected'); $(document).unbind('jarnxmpp.connected');
...@@ -1513,7 +1492,7 @@ ...@@ -1513,7 +1492,7 @@
this.connection.muc_domain = 'conference.' + this.connection.domain; this.connection.muc_domain = 'conference.' + this.connection.domain;
this.roster = new RosterItems(); this.roster = new RosterItems();
_.extend(this.roster, this.Roster); //_.extend(this.roster, this.Roster);
this.rosterview = Backbone.View.extend(this.RosterView(this.roster, _, $, console)); this.rosterview = Backbone.View.extend(this.RosterView(this.roster, _, $, console));
this.connection.addHandler( this.connection.addHandler(
......
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