From 309d2de7c749b2e82988a78181d71e718c8298fb Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sun, 4 Mar 2018 07:45:36 +0000 Subject: [PATCH] Hide roles label in usercard if there is no roles to be displayed --- webapp/titanembeds/static/js/embed.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index b05a436..527881a 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -803,11 +803,13 @@ return parseFloat(b.position) - parseFloat(a.position); }); $("#usercard .role .roles").empty(); + var rolecount = 0; for (var j = 0; j < data.roles.length; j++) { var role = data.roles[j]; if (role.id == guild_id) { continue; } + rolecount++; var color = null; if (role.color) { color = "#" + role.color.toString(16); @@ -815,6 +817,11 @@ var rol = Mustache.render(template, {name: role.name, color: color}); $("#usercard .role .roles").append(rol); } + if (rolecount) { + $("#usercard .role").show(); + } else { + $("#usercard .role").hide(); + } $("#usercard-mention-btn").off("click"); $("#usercard-mention-btn").click(function () {