mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 20:13:07 +00:00
Added user modes. Close #7
This commit is contained in:
parent
b730e60582
commit
bc534e9a04
4 changed files with 28 additions and 5 deletions
|
@ -68,7 +68,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{#each users}}
|
{{#each users}}
|
||||||
<button class="user">
|
<button class="user">
|
||||||
{{name}}
|
{{mode}}{{name}}
|
||||||
</button>
|
</button>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -11,3 +11,19 @@ function Chan(attr) {
|
||||||
users: [],
|
users: [],
|
||||||
}, attr));
|
}, attr));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Chan.prototype = {
|
||||||
|
sortUsers: function() {
|
||||||
|
this.users = _.sortBy(
|
||||||
|
this.users,
|
||||||
|
function(u) { return u.name.toLowerCase(); }
|
||||||
|
);
|
||||||
|
var modes = ["+", "@"];
|
||||||
|
modes.forEach(function(mode) {
|
||||||
|
this.users = _.remove(
|
||||||
|
this.users,
|
||||||
|
function(u) { return u.mode == mode; }
|
||||||
|
).concat(this.users);
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -264,6 +264,7 @@ function event(e, data) {
|
||||||
}
|
}
|
||||||
var users = chan.users;
|
var users = chan.users;
|
||||||
users.push(new User({name: data.nick}));
|
users.push(new User({name: data.nick}));
|
||||||
|
chan.sortUsers();
|
||||||
sockets.emit("users", {
|
sockets.emit("users", {
|
||||||
id: chan.id,
|
id: chan.id,
|
||||||
users: users,
|
users: users,
|
||||||
|
@ -309,6 +310,7 @@ function event(e, data) {
|
||||||
case "mode":
|
case "mode":
|
||||||
var chan = _.findWhere(channels, {name: data.target});
|
var chan = _.findWhere(channels, {name: data.target});
|
||||||
if (typeof chan !== "undefined") {
|
if (typeof chan !== "undefined") {
|
||||||
|
this.client.write("NAMES " + data.target);
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: "mode",
|
type: "mode",
|
||||||
from: data.nick,
|
from: data.nick,
|
||||||
|
@ -377,9 +379,13 @@ function event(e, data) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
chan.users = [];
|
chan.users = [];
|
||||||
data.names.forEach(function(n) {
|
for (var n in data.names) {
|
||||||
chan.users.push(new User({name: n}));
|
chan.users.push(new User({
|
||||||
});
|
mode: data.names[n],
|
||||||
|
name: n
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
chan.sortUsers();
|
||||||
sockets.emit("users", {
|
sockets.emit("users", {
|
||||||
id: chan.id,
|
id: chan.id,
|
||||||
users: chan.users,
|
users: chan.users,
|
||||||
|
@ -405,6 +411,7 @@ function event(e, data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.name = data["new"];
|
user.name = data["new"];
|
||||||
|
chan.sortUsers();
|
||||||
sockets.emit("users", {
|
sockets.emit("users", {
|
||||||
id: chan.id,
|
id: chan.id,
|
||||||
users: chan.users,
|
users: chan.users,
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash": "~2.4.1",
|
"lodash": "~2.4.1",
|
||||||
"slate-irc": "~0.5.0",
|
"slate-irc": "https://github.com/erming/slate-irc/tarball/master",
|
||||||
"moment": "~2.5.1",
|
"moment": "~2.5.1",
|
||||||
"connect": "~2.14.3",
|
"connect": "~2.14.3",
|
||||||
"socket.io": "~0.9.16"
|
"socket.io": "~0.9.16"
|
||||||
|
|
Loading…
Reference in a new issue