From 7484e578546d6fb661250fe783e02345109dd68e Mon Sep 17 00:00:00 2001 From: Anuj Kumar Sharma Date: Sat, 12 Oct 2024 23:26:57 +0530 Subject: [PATCH] Removed display of brief article description in popovers #1276 (#1278) Signe off by @THEBOSS0369 --- www/js/lib/popovers.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/www/js/lib/popovers.js b/www/js/lib/popovers.js index c4c829a45..7155fe973 100644 --- a/www/js/lib/popovers.js +++ b/www/js/lib/popovers.js @@ -99,12 +99,20 @@ function getArticleLede (href, baseUrl, articleDocument, archive) { // Helper function to clean up the lede content function cleanUpLedeContent (node) { + // Define an array of exclusion filters + // (note `.exclude-this-class` is a dummy class used as an example for any future exclusion filters) + const exclusionFilters = ['#pcs-edit-section-title-description', '.exclude-this-class']; + // Construct the `:not()` CSS exclusion selector list + const notSelector = exclusionFilters.map(filter => `:not(${filter})`).join(''); + // Remove all standalone style elements from the given DOM node, because their content is shown by innerText and textContent const styleElements = Array.from(node.querySelectorAll('style')); styleElements.forEach(style => { style.parentNode.removeChild(style); }); - const paragraphs = Array.from(node.querySelectorAll('p')); + // Apply this style-based exclusion filter to remove unwanted paragraphs in the popover + const paragraphs = Array.from(node.querySelectorAll(`p${notSelector}`)); + // Filter out empty paragraphs or those with less than 50 characters const parasWithContent = paragraphs.filter(para => { // DEV: Note that innerText is not supported in Firefox OS, so we need to use textContent as a fallback