aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Kavlie <akavlie@gmail.com>2011-11-04 23:16:29 -0700
committerAaron Kavlie <akavlie@gmail.com>2011-11-04 23:16:29 -0700
commit413ff06c6bb91bb7f8c366845f86cad7e6ec06b1 (patch)
treef2509d8c32193dd88948ced4f3920f1a74c3fe73
parent5d0e8b93e16261cfa4d2d4c5bddd99a38a9fa0cc (diff)
downloadreevo-webirc-413ff06c6bb91bb7f8c366845f86cad7e6ec06b1.tar.gz
reevo-webirc-413ff06c6bb91bb7f8c366845f86cad7e6ec06b1.zip
Add nick change notifications. Works for channel stream; not yet for changing in sidebar.
-rw-r--r--app.js31
-rw-r--r--server.js1
2 files changed, 32 insertions, 0 deletions
diff --git a/app.js b/app.js
index 820d8ff..9ca9486 100644
--- a/app.js
+++ b/app.js
@@ -26,6 +26,9 @@ $(function() {
26 case 'part': 26 case 'part':
27 text = this.get('nick') + ' left the channel'; 27 text = this.get('nick') + ' left the channel';
28 break; 28 break;
29 case 'nick':
30 text = this.get('oldNick') + ' is now known as ' + this.get('newNick');
31 break;
29 } 32 }
30 this.set({text: text}); 33 this.set({text: text});
31 } 34 }
@@ -91,6 +94,12 @@ $(function() {
91 }); 94 });
92 95
93 frame.set({active: true}); 96 frame.set({active: true});
97 },
98
99 getChannels: function() {
100 return this.filter(function(frame) {
101 return frame.get('type') == 'channel';
102 });
94 } 103 }
95 104
96 }); 105 });
@@ -409,6 +418,28 @@ $(function() {
409 } 418 }
410 }); 419 });
411 420
421 socket.on('nick', function(data) {
422 // Update my info, if it's me
423 if (data.oldNick == irc.me.get('nick')) {
424 irc.me.set({nick: data.newNick});
425 }
426
427 // Set new name in all channels
428 data.channels.forEach(function(ch) {
429 var channel = frames.getByName(ch);
430 // Change nick in user list
431 channel.participants.getByNick(data.oldNick).set({nick: data.newNick});
432 // Send nick change message to channel stream
433 var nickMessage = new Message({
434 type: 'nick',
435 oldNick: data.oldNick,
436 newNick: data.newNick
437 });
438 nickMessage.setText()
439 channel.stream.add(nickMessage);
440 });
441 });
442
412 socket.on('names', function(data) { 443 socket.on('names', function(data) {
413 var frame = frames.getByName(data.channel); 444 var frame = frames.getByName(data.channel);
414 console.log(data); 445 console.log(data);
diff --git a/server.js b/server.js
index 0f3b9a3..0dd22ef 100644
--- a/server.js
+++ b/server.js
@@ -45,6 +45,7 @@ io.sockets.on('connection', function(socket) {
45 var events = { 45 var events = {
46 'join': ['channel', 'nick'], 46 'join': ['channel', 'nick'],
47 'part': ['channel', 'nick'], 47 'part': ['channel', 'nick'],
48 'nick': ['oldNick', 'newNick', 'channels'],
48 'names': ['channel', 'nicks'], 49 'names': ['channel', 'nicks'],
49 'message': ['from', 'to', 'text'], 50 'message': ['from', 'to', 'text'],
50 'motd': ['motd'], 51 'motd': ['motd'],