diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-03-19 20:51:37 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-02-25 20:03:28 -0400 |
commit | 73da644065a191d6d77237395a8684cc2f665e0c (patch) | |
tree | f260bb4c90149fc036b55116985a13fd1b70ae6a /src | |
parent | 9d4080b003c8786e6b1faecd90c304d39e413af9 (diff) |
content: listArtTagNetwork: descendants (leaves only) stat
Diffstat (limited to 'src')
-rw-r--r-- | src/content/dependencies/listArtTagNetwork.js | 20 | ||||
-rw-r--r-- | src/static/js/client/art-tag-network.js | 11 | ||||
-rw-r--r-- | src/strings-default.yaml | 6 |
3 files changed, 35 insertions, 2 deletions
diff --git a/src/content/dependencies/listArtTagNetwork.js b/src/content/dependencies/listArtTagNetwork.js index c975c07e..938688b8 100644 --- a/src/content/dependencies/listArtTagNetwork.js +++ b/src/content/dependencies/listArtTagNetwork.js @@ -39,6 +39,13 @@ export default { descendants: artTag.allDescendantArtTags.length, + + leaves: + (empty(artTag.directDescendantArtTags) + ? null + : artTag.allDescendantArtTags + .filter(artTag => empty(artTag.directDescendantArtTags)) + .length), }); const recursive = (artTag, depth) => { @@ -147,6 +154,9 @@ export default { descendants: queryNode.stats.descendants, + leaves: + queryNode.stats.leaves, + representsRoot: rootArtTags.includes(queryNode.artTag), @@ -214,6 +224,11 @@ export default { html.tag('span', {class: 'network-tag-descendants-stat'}, dataNode.descendants.toString()), + + html.tag('span', {class: 'network-tag-leaves-stat'}, + (dataNode.leaves === null + ? language.$(prefix, 'tag.withStat.notApplicable') + : dataNode.leaves.toString())), ], })), })) @@ -290,6 +305,11 @@ export default { {href: '#'}, {style: 'display: none'}, language.$(prefix, 'statLine.descendants')), + + html.tag('a', {id: 'network-stat-leaves'}, + {href: '#'}, + {style: 'display: none'}, + language.$(prefix, 'statLine.leaves')), ], })), diff --git a/src/static/js/client/art-tag-network.js b/src/static/js/client/art-tag-network.js index fc5f6526..44e10c11 100644 --- a/src/static/js/client/art-tag-network.js +++ b/src/static/js/client/art-tag-network.js @@ -11,6 +11,7 @@ export const info = { totalUsesStatLink: null, directUsesStatLink: null, descendantsStatLink: null, + leavesStatLink: null, tagsWithoutStats: null, tagsWithStats: null, @@ -18,6 +19,7 @@ export const info = { totalUsesStats: null, directUsesStats: null, descendantsStats: null, + leavesStats: null, }; export function getPageReferences() { @@ -40,6 +42,9 @@ export function getPageReferences() { info.descendantsStatLink = document.getElementById('network-stat-descendants'); + info.leavesStatLink = + document.getElementById('network-stat-leaves'); + info.tagsWithoutStats = document.querySelectorAll('.network-tag:not(.with-stat)'); @@ -54,6 +59,9 @@ export function getPageReferences() { info.descendantsStats = Array.from(document.getElementsByClassName('network-tag-descendants-stat')); + + info.leavesStats = + Array.from(document.getElementsByClassName('network-tag-leaves-stat')); } export function addPageListeners() { @@ -64,6 +72,7 @@ export function addPageListeners() { info.totalUsesStatLink, info.directUsesStatLink, info.descendantsStatLink, + info.leavesStatLink, ]; const statsOrder = [ @@ -71,6 +80,7 @@ export function addPageListeners() { info.totalUsesStats, info.directUsesStats, info.descendantsStats, + info.leavesStats, ]; const stitched = @@ -110,6 +120,7 @@ function showArtTagNetworkStats(stats) { ...info.totalUsesStats, ...info.directUsesStats, ...info.descendantsStats, + ...info.leavesStats, ]; const otherStats = diff --git a/src/strings-default.yaml b/src/strings-default.yaml index 0d86249a..92b86bd7 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -1713,9 +1713,10 @@ listingPage: statLine: _: "Displaying tag info: {STAT}" none: "name only" - directUses: "uses (direct only)" totalUses: "uses (total)" - descendants: "descendants" + directUses: "uses (direct only)" + descendants: "descendants (total)" + leaves: "descendants (leaves only)" root: _: "{TAG}" @@ -1735,6 +1736,7 @@ listingPage: withStat: _: "{STAT} {TAG}" stat: "({STAT})" + notApplicable: "-" orphanArtTags: title: "These tags don't have any descendants or ancestors:" |