Skip to content

Commit

Permalink
Fixed names support, you now actually see who is in the channel upon …
Browse files Browse the repository at this point in the history
…joining.
  • Loading branch information
DanBUK committed Feb 7, 2011
1 parent af96267 commit dba77ef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
16 changes: 15 additions & 1 deletion irc.js
Expand Up @@ -33,7 +33,7 @@ socket.on('connection', function(client) {
irc = new ircjs({
server: 'holmes.freenode.net',
port: 6667,
nick: obj.nickname,
nick: nickname,
user: {
username: nickname,
hostname: 'irc.bejes.us',
Expand All @@ -57,6 +57,19 @@ socket.on('connection', function(client) {
}
});
irc.addListener('join', function (message) {
if (message.person.nick == nickname) {
setTimeout(function () {
irc.names("#nodester", function (chan, names) {
for(var i in names) {
client.send(JSON.stringify({
messagetype: "join",
from: names[i],
channel: chan
}));
}
})
}, 1500);
};
client.send(JSON.stringify({
messagetype: "join",
from: message.person.nick,
Expand All @@ -70,6 +83,7 @@ socket.on('connection', function(client) {
channel: message.params[0]
}));
});

irc.addListener('error', function () {console.log(arguments)});
} else {
// Maybe handle updaing of nicks one day :)
Expand Down
16 changes: 9 additions & 7 deletions public/index.html
Expand Up @@ -89,12 +89,14 @@
scrollBody();
};
var addNickToList = function (nick) {
var li = document.createElement('li');
li.value = nick;
li.textContent = nick;
nick_lis[nick] = li;
nick_ul.appendChild(li);
sortList(nick_ul);
if (!nick_lis.hasOwnProperty(nick)) {
var li = document.createElement('li');
li.value = nick;
li.textContent = nick;
nick_lis[nick] = li;
nick_ul.appendChild(li);
sortList(nick_ul);
}
};
var delNickFromList = function (nick) {
if (nick_lis.hasOwnProperty(nick)) {
Expand Down Expand Up @@ -169,7 +171,7 @@
HTMLElement.prototype.__defineGetter__("innerText", function () {
var r = this.ownerDocument.createRange();
r.selectNodeContents(this);
return r.toString().toLowerCase();
return r.toString();
});
}
</script>
Expand Down

0 comments on commit dba77ef

Please sign in to comment.