Sort users

This commit is contained in:
Mattias Erming 2014-04-10 00:35:04 +02:00
parent 541e41e804
commit 7c3cf140d8
2 changed files with 14 additions and 6 deletions

View File

@ -220,7 +220,7 @@ $(function() {
var id = parseInt(link.closest(".window").attr("id").replace("window-", ""));
socket.emit("input", {
id: id,
text: "/whois " + link.text(),
text: "/whois " + link.text().trim(),
});
});

View File

@ -219,7 +219,9 @@ function event(event, data) {
case "join":
var chan = channels.findWhere({name: data[0].channel}) || channels.add({name: data[0].channel});
chan.addUser({name: data[0].nick});
var users = chan.get("users");
users.add({name: data[0].nick});
users.sort();
chan.addMessage({
from: data[0].nick,
type: "join",
@ -271,11 +273,13 @@ function event(event, data) {
case "names":
var chan = channels.findWhere({name: data[0].channel});
chan.get("users").reset(
_.map(data[0].names, function(n) {
return {name: n};
})
var users = chan.get("users");
users.reset(
_.map(data[0].names, function(n) { return {name: n}; }),
{silent: true}
);
users.sort();
users.trigger("reset", {}, users);
break;
case "nick":
@ -292,6 +296,8 @@ function event(event, data) {
}
user.set("name", data[0]["new"]);
users.sort();
users.trigger("change", {}, users);
chan.addMessage({
@ -317,6 +323,7 @@ function event(event, data) {
}
var users = chan.get("users");
users.remove(users.findWhere({name: data[0].nick}));
users.sort();
chan.addMessage({
from: data[0].nick,
type: "part",
@ -329,6 +336,7 @@ function event(event, data) {
var user = users.findWhere({name: data[0].nick});
if (user) {
users.remove(user);
users.sort();
chan.addMessage({
from: data[0].nick,
type: "quit",