Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #49 from thedjpetersen/42/feature/quits

Support for quits on channels
  • Loading branch information...
commit 70fcdaecbe717e08cd86c77cd633bccd48a5de20 2 parents 2ef1cdf + 5bae8df
@thedjpetersen authored
View
16 assets/js/client.js
@@ -43,7 +43,7 @@ $(function() {
//irc.chatWindows.getByName('status').stream.add({sender: 'notice', raw: data.text, type: 'notice'});
});
- irc.socket.on('nick', function(data) {
+ irc.socket.on('getNick', function(data) {
irc.me.nick = data.nick;
});
@@ -109,6 +109,20 @@ $(function() {
}
});
+ irc.socket.on('quit', function(data) {
+ var channel, user, quitMessage;
+ for(var i=0; i<data.channels.length; i++){
+ channel = irc.chatWindows.getByName(data.channels[i]);
+ if(channel !== undefined) {
+ user = channel.userList.getByNick(data.nick);
+ user.view.remove();
+ user.destroy();
+ quitMessage = new Message({type: 'quit', nick: data.nick, reason: data.reason, message: data.message});
+ channel.stream.add(quitMessage);
+ }
+ }
+ });
+
irc.socket.on('names', function(data) {
var channel = irc.chatWindows.getByName(data.channel);
channel.userList = new UserList(channel);
View
4 assets/js/views/chat.js
@@ -108,11 +108,11 @@ var ChatView = Backbone.View.extend({
$chatWindow.append(view.el);
- if (sender === irc.me.nick && ['join', 'part'].indexOf(type) === -1) {
+ if (sender === irc.me.nick && 'message'.indexOf(type) === 0) {
$(view.el).addClass('message-me');
}
- if(['join', 'part', 'topic'].indexOf(type) !== -1){
+ if(['join', 'part', 'topic', 'quit'].indexOf(type) !== -1){
$(view.el).addClass('message_notification');
}
View
11 assets/js/views/message.js
@@ -9,7 +9,7 @@ var MessageView = Backbone.View.extend({
var nick = this.model.get('sender') || this.model.collection.channel.get('name');
var html;
- if (_.include(['join', 'part', 'nick', 'topic'], this.model.get('type')))
+ if (_.include(['join', 'part', 'nick', 'topic', 'quit'], this.model.get('type')))
html = this.setText(this.model.get('type'));
// This handles whether to output a message or an action
else if (this.model.get('text').substr(1, 6) === 'ACTION') {
@@ -46,6 +46,15 @@ var MessageView = Backbone.View.extend({
action: type === 'join' ? 'joined' : 'left'
});
break;
+ case 'quit':
+ html = ich.join_part({
+ type: 'part',
+ nick: this.model.get('nick'),
+ action: 'left',
+ reason: '(' + this.model.get('reason') + ')',
+ message: '(' + this.model.get('message') + ')'
+ });
+ break
case 'nick':
html = ich.nick({
oldNick: this.model.get('oldNick'),
View
3  lib/irchandler.js
@@ -5,6 +5,7 @@ var irchandler = exports.irchandler = function(socket) {
var events = {
'join': ['channel', 'nick'],
'part': ['channel', 'nick'],
+ 'quit': ['nick', 'reason', 'channels', 'message'],
'topic': ['channel', 'topic', 'nick'],
'nick': ['oldNick', 'newNick', 'channels'],
'names': ['channel', 'nicks'],
@@ -38,7 +39,7 @@ var irchandler = exports.irchandler = function(socket) {
});
socket.on('getNick', function(data) {
- socket.emit('nick', {nick: client.nick});
+ socket.emit('getNick', {nick: client.nick});
});
socket.on('command', function(text) { console.log(text); client.send(text); });
View
2  views/templates.jade
@@ -110,7 +110,7 @@ script(id="message", type="text/html")
script(id="join_part", type="text/html")
span(class="{{type}}_img")
- span <b>{{nick}}</b> {{action}} the channel
+ span <b>{{nick}}</b> {{action}} the channel {{reason}} {{message}}
script(id="nick", type="text/html")
span <b>{{oldNick}}</b> is now known as {{newNick}}
Please sign in to comment.
Something went wrong with that request. Please try again.