« get me outta code hell

only divide ref list if official group present - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-03-03 13:30:29 -0400
committer(quasar) nebula <towerofnix@gmail.com>2021-03-03 13:30:29 -0400
commit8202005413171124c41e32bb02eea4414cc4ef37 (patch)
tree1c0cce5314636831ed7168c8b7961a7795c606e2
parent5d70e99ac2b15630a436bf9d36772b2e0c9c19d3 (diff)
only divide ref list if official group present
-rw-r--r--strings-default.json2
-rwxr-xr-xupd8.js32
2 files changed, 22 insertions, 12 deletions
diff --git a/strings-default.json b/strings-default.json
index 20806a5f..10430c77 100644
--- a/strings-default.json
+++ b/strings-default.json
@@ -247,6 +247,8 @@
     "tagPage.infoLine": "Appears in {COVER_ARTS}.",
     "tagPage.nav.tag": "Tag: {TAG}",
     "trackPage.title": "{TRACK}",
+    "trackPage.referenceList.fandom": "Fandom:",
+    "trackPage.referenceList.official": "Official:",
     "trackPage.nav.track": "{TRACK}",
     "trackPage.nav.track.withNumber": "{NUMBER}. {TRACK}",
     "trackPage.nav.random": "Random"
diff --git a/upd8.js b/upd8.js
index 8f40c45e..30545854 100755
--- a/upd8.js
+++ b/upd8.js
@@ -2728,9 +2728,14 @@ function writeTrackPages() {
 
 function writeTrackPage(track) {
     const { album } = track;
+
     const tracksThatReference = track.referencedBy;
-    const ttrFanon = tracksThatReference.filter(t => t.album.groups.every(group => group.directory !== C.OFFICIAL_GROUP_DIRECTORY));
-    const ttrOfficial = tracksThatReference.filter(t => t.album.groups.some(group => group.directory === C.OFFICIAL_GROUP_DIRECTORY));
+    const useDividedReferences = groupData.some(group => group.directory === C.OFFICIAL_GROUP_DIRECTORY);
+    const ttrFanon = (useDividedReferences &&
+        tracksThatReference.filter(t => t.album.groups.every(group => group.directory !== C.OFFICIAL_GROUP_DIRECTORY)));
+    const ttrOfficial = (useDividedReferences &&
+        tracksThatReference.filter(t => t.album.groups.some(group => group.directory === C.OFFICIAL_GROUP_DIRECTORY)));
+
     const tracksReferenced = track.references;
     const otherReleases = track.otherReleases;
     const listTag = getAlbumListTag(track.album);
@@ -2865,16 +2870,19 @@ function writeTrackPage(track) {
                 `}
                 ${tracksThatReference.length && fixWS`
                     <p>${strings('releaseInfo.tracksThatReference', {track: `<i>${track.name}</i>`})}</p>
-                    <dl>
-                        ${ttrOfficial.length && fixWS`
-                            <dt>Official:</dt>
-                            <dd>${generateTrackList(ttrOfficial, {strings, to})}</dd>
-                        `}
-                        ${ttrFanon.length && fixWS`
-                            <dt>Fandom:</dt>
-                            <dd>${generateTrackList(ttrFanon, {strings, to})}</dd>
-                        `}
-                    </dl>
+                    ${useDividedReferences && fixWS`
+                        <dl>
+                            ${ttrOfficial.length && fixWS`
+                                <dt>${strings('trackPage.referenceList.official')}</dt>
+                                <dd>${generateTrackList(ttrOfficial, {strings, to})}</dd>
+                            `}
+                            ${ttrFanon.length && fixWS`
+                                <dt>${strings('trackPage.referenceList.fandom')}</dt>
+                                <dd>${generateTrackList(ttrFanon, {strings, to})}</dd>
+                            `}
+                        </dl>
+                    `}
+                    ${!useDividedReferences && generateTrackList(tracksThatReference, {strings, to})}
                 `}
                 ${wikiInfo.features.flashesAndGames && flashesThatFeature.length && fixWS`
                     <p>${strings('releaseInfo.flashesThatFeature', {track: `<i>${track.name}</i>`})}</p>