mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 12:03:11 +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>
|
||||
{{#each users}}
|
||||
<button class="user">
|
||||
{{name}}
|
||||
{{mode}}{{name}}
|
||||
</button>
|
||||
{{/each}}
|
||||
</script>
|
||||
|
|
|
@ -11,3 +11,19 @@ function Chan(attr) {
|
|||
users: [],
|
||||
}, 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;
|
||||
users.push(new User({name: data.nick}));
|
||||
chan.sortUsers();
|
||||
sockets.emit("users", {
|
||||
id: chan.id,
|
||||
users: users,
|
||||
|
@ -309,6 +310,7 @@ function event(e, data) {
|
|||
case "mode":
|
||||
var chan = _.findWhere(channels, {name: data.target});
|
||||
if (typeof chan !== "undefined") {
|
||||
this.client.write("NAMES " + data.target);
|
||||
var msg = new Msg({
|
||||
type: "mode",
|
||||
from: data.nick,
|
||||
|
@ -377,9 +379,13 @@ function event(e, data) {
|
|||
break;
|
||||
}
|
||||
chan.users = [];
|
||||
data.names.forEach(function(n) {
|
||||
chan.users.push(new User({name: n}));
|
||||
});
|
||||
for (var n in data.names) {
|
||||
chan.users.push(new User({
|
||||
mode: data.names[n],
|
||||
name: n
|
||||
}));
|
||||
}
|
||||
chan.sortUsers();
|
||||
sockets.emit("users", {
|
||||
id: chan.id,
|
||||
users: chan.users,
|
||||
|
@ -405,6 +411,7 @@ function event(e, data) {
|
|||
return;
|
||||
}
|
||||
user.name = data["new"];
|
||||
chan.sortUsers();
|
||||
sockets.emit("users", {
|
||||
id: chan.id,
|
||||
users: chan.users,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"lodash": "~2.4.1",
|
||||
"slate-irc": "~0.5.0",
|
||||
"slate-irc": "https://github.com/erming/slate-irc/tarball/master",
|
||||
"moment": "~2.5.1",
|
||||
"connect": "~2.14.3",
|
||||
"socket.io": "~0.9.16"
|
||||
|
|
Loading…
Reference in a new issue