Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Private messages from users have correct class, getOldMessages before…

… sending message
  • Loading branch information...
commit 613725652c8085d7b97fa65c7548302611e6a27a 1 parent 3cd6bb4
@dj-emberex dj-emberex authored
Showing with 13 additions and 13 deletions.
  1. +11 −11 assets/js/client.js
  2. +2 −2 assets/js/views/chat.js
View
22 assets/js/client.js
@@ -34,7 +34,7 @@ $(function() {
irc.socket.emit('getDatabaseState', {});
irc.socket.on('databaseState', function(data) {
- if(data.state == 0){
+ if(data.state === 0){
$('#login, #register').hide();
}
});
@@ -118,13 +118,6 @@ $(function() {
chatWindow.stream.add({sender: data.from, raw: data.text, type: type});
} else if(data.to !== irc.me.get('nick')) {
// Handle PMs intiated by me
- if (typeof chatWindow === 'undefined') {
- var myNick = irc.me.get('nick');
- var logname = (myNick < data.to) ? myNick + data.to : data.to + myNick;
- irc.chatWindows.add({name: data.to, type: 'pm'});
- irc.socket.emit('getOldMessages',{channelName: logname, skip:-50, amount: 50});
- chatWindow = irc.chatWindows.getByName(data.to);
- }
chatWindow.stream.add({sender: data.from, raw: data.text, type: 'pm'});
}
});
@@ -300,8 +293,15 @@ $(function() {
case '/query':
case '/privmsg':
case '/msg':
+ var target = commandText[1];
+ var myNick = irc.me.get('nick');
+ var logname = (myNick < target) ? myNick + target : target + myNick;
+ if (typeof irc.chatWindows.getByName(target) === 'undefined') {
+ irc.chatWindows.add({name: target, type: 'pm'});
+ }
+ irc.socket.emit('getOldMessages',{channelName: logname, skip:-50, amount: 50});
irc.socket.emit('say', {
- target: commandText[1],
+ target: target,
message: commandText.splice(2).join(" ")
});
break;
@@ -309,7 +309,7 @@ $(function() {
commandText[0] = commandText[0].substr(1).toUpperCase();
irc.socket.emit('command', commandText);
}
- }
+ };
-})
+});
View
4 assets/js/views/chat.js
@@ -150,7 +150,7 @@ var ChatView = Backbone.View.extend({
$chatWindow.append(view.el);
- if (sender === irc.me.get('nick') && 'message'.indexOf(type) === 0) {
+ if (sender === irc.me.get('nick') && ['message', 'pm'].indexOf(type) !== -1) {
$(view.el).addClass('message-me');
}
@@ -200,5 +200,5 @@ var ChatView = Backbone.View.extend({
$(this).siblings('.hide_embed').removeClass('hide');
$(this).addClass('hide');
});
- },
+ }
});
Please sign in to comment.
Something went wrong with that request. Please try again.