From f465669db16fd61328285cf6ec138aca85fc3e81 Mon Sep 17 00:00:00 2001 From: gravel Date: Thu, 19 Jan 2023 19:35:46 +0100 Subject: [PATCH] Exclude dead servers from hidden group tally --- output/main.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/output/main.js b/output/main.js index d466c21..6809a51 100644 --- a/output/main.js +++ b/output/main.js @@ -86,8 +86,10 @@ function hideBadCommunities() { let numberOfHiddenCommunities = 0; for (const category of ['tests', 'offensive', 'legacy']) { - filteredCommunities[category].forEach(hideElementByID); - numberOfHiddenCommunities += filteredCommunities[category].length; + numberOfHiddenCommunities += + filteredCommunities[category] + .map(hideElementByID) + .reduce((a, b) => a + b); } // Not ideal. Separate element should be allocated for content. @@ -95,8 +97,13 @@ function hideBadCommunities() { summary.innerText += ` (${numberOfHiddenCommunities} hidden)`; } +/** + * Removes an element by its ID and returns the number of elements removed. + */ function hideElementByID(id) { - document.getElementById(id)?.remove(); + const element = document.getElementById(id); + element?.remove(); + return element ? 1 : 0; } /**