Work on index page
This commit is contained in:
parent
24fcce3f87
commit
7307c9c82e
3 changed files with 71 additions and 1 deletions
|
|
@ -255,6 +255,49 @@ Server.prototype.unloadChannel = function (chan) {
|
|||
chan.dead = true;
|
||||
};
|
||||
|
||||
Server.prototype.packChannelList = function (publicOnly) {
|
||||
var channels = this.channels.filter(function (c) {
|
||||
if (!publicOnly) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return c.opts.show_public && !c.opts.password;
|
||||
});
|
||||
|
||||
return channels.map(this.packChannel.bind(this));
|
||||
};
|
||||
|
||||
Server.prototype.packChannel = function (c) {
|
||||
var data = {
|
||||
name: c.name,
|
||||
pagetitle: c.opts.pagetitle,
|
||||
mediatitle: c.playlist.current ? c.playlist.current.media.title : "-",
|
||||
usercount: c.users.length,
|
||||
voteskip_eligible: c.calcVoteskipMax(),
|
||||
users: [],
|
||||
chat: Array.prototype.slice.call(c.chatbuffer)
|
||||
};
|
||||
|
||||
for (var i = 0; i < c.users.length; i++) {
|
||||
if (c.users[i].name !== "") {
|
||||
var name = c.users[i].name;
|
||||
var rank = c.users[i].rank;
|
||||
if (rank >= 255) {
|
||||
name = "!" + name;
|
||||
} else if (rank >= 4) {
|
||||
name = "~" + name;
|
||||
} else if (rank >= 3) {
|
||||
name = "&" + name;
|
||||
} else if (rank >= 2) {
|
||||
name = "@" + name;
|
||||
}
|
||||
data.users.push(name);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
Server.prototype.logHTTP = function (req, status) {
|
||||
if (status === undefined)
|
||||
status = 200;
|
||||
|
|
|
|||
|
|
@ -101,9 +101,11 @@ function handleIndex(req, res) {
|
|||
if (req.cookies.auth) {
|
||||
loginName = req.cookies.auth.split(':')[0];
|
||||
}
|
||||
|
||||
sendJade(res, 'index', {
|
||||
loggedIn: loginName !== false,
|
||||
loginName: loginName
|
||||
loginName: loginName,
|
||||
channels: Server.getServer().packChannelList(true)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue