From 517e6f4ced5503c9668ff68274f4c810569dea2b Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Fri, 21 Apr 2017 23:35:30 -0700 Subject: [PATCH] Member counts for sidebar --- titanembeds/static/js/embed.js | 7 ++++++- titanembeds/templates/embed.html.j2 | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/titanembeds/static/js/embed.js b/titanembeds/static/js/embed.js index e5aa108..84d0d30 100644 --- a/titanembeds/static/js/embed.js +++ b/titanembeds/static/js/embed.js @@ -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}); diff --git a/titanembeds/templates/embed.html.j2 b/titanembeds/templates/embed.html.j2 index b59dfb7..45c0e75 100644 --- a/titanembeds/templates/embed.html.j2 +++ b/titanembeds/templates/embed.html.j2 @@ -55,15 +55,15 @@