Member counts for sidebar

This commit is contained in:
Jeremy Zhang 2017-04-21 23:35:30 -07:00
parent f22bc439e7
commit 517e6f4ced
2 changed files with 9 additions and 4 deletions

View File

@ -207,12 +207,14 @@
var template_user = $('#mustache_authedusers').html();
Mustache.parse(template_user);
$("#discord-members").empty();
var discordmembercnt = 0;
for (var i = 0; i < guild_members_arr.length; i++) {
var roleobj = guild_members_arr[i];
if (!roleobj["name"]) {
roleobj["name"] = "Uncategorized";
}
var rendered_role = Mustache.render(template_role, {"name": roleobj["name"]});
var rendered_role = Mustache.render(template_role, {"name": roleobj["name"] + " - " + roleobj["members"].length});
discordmembercnt += roleobj["members"].length;
$("#discord-members").append(rendered_role);
for (var j = 0; j < roleobj.members.length; j++) {
var member = roleobj.members[j];
@ -226,12 +228,14 @@
}
}
}
$("#discord-members-count").html(discordmembercnt);
}
function fill_authenticated_users(users) {
var template = $('#mustache_authedusers').html();
Mustache.parse(template);
$("#embed-discord-members").empty();
$("#embed-discord-members-count").html(users.length);
for (var i = 0; i < users.length; i++) {
var member = users[i];
var rendered = Mustache.render(template, {"id": member.id.toString() + "a", "username": member.username, "avatar": member.avatar_url});
@ -246,6 +250,7 @@
var template = $('#mustache_unauthedusers').html();
Mustache.parse(template);
$("#embed-unauth-users").empty();
$("#guest-members-count").html(users.length);
for (var i = 0; i < users.length; i++) {
var member = users[i];
var rendered = Mustache.render(template, {"username": member.username, "discriminator": member.discriminator});

View File

@ -55,15 +55,15 @@
</ul>
<ul id="members-nav" class="side-nav">
<li><a class="subheader">Online Server Members</a></li>
<li><a class="subheader">Online Server Members - <span id="discord-members-count"></span></a></li>
<span id="discord-members"></span>
<li><div class="divider"></div></li>
<li><a class="subheader">Authenticated Embed Users</a></li>
<li><a class="subheader">Authenticated Embed Users - <span id="embed-discord-members-count"></span></a></li>
<span id="embed-discord-members"></span>
<li><a class="subheader">Guest Embed Users</a></li>
<li><a class="subheader">Guest Embed Users - <span id="guest-members-count"></span></a></li>
<span id="embed-unauth-users"></span>
</ul>