« get me outta code hell

only show "Random" nav links when JS is enabled - 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>2020-10-30 10:20:32 -0300
committer(quasar) nebula <towerofnix@gmail.com>2020-10-30 10:20:32 -0300
commit5b320f6ece7ccb8cd1acc15ea517cceb13983cf4 (patch)
treee81e8e59477adfcdafa811ccb09bb5fb39898132
parentb28371c3028b1045280ccdad986b445a87be1c6c (diff)
only show "Random" nav links when JS is enabled
-rw-r--r--upd8.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/upd8.js b/upd8.js
index 173fcc77..2c64b816 100644
--- a/upd8.js
+++ b/upd8.js
@@ -2403,11 +2403,18 @@ function generateAlbumNavLinks(album, currentTrack = null) {
     const index = currentTrack && album.tracks.indexOf(currentTrack)
     const previous = currentTrack && album.tracks[index - 1]
     const next = currentTrack && album.tracks[index + 1]
-    return `(${[
+
+    const [ previousLine, nextLine, randomLine ] = [
         previous && `<a href="${C.TRACK_DIRECTORY}/${previous.directory}/index.html" id="previous-button" title="${previous.name}">Previous</a>`,
         next && `<a href="${C.TRACK_DIRECTORY}/${next.directory}/index.html" id="next-button" title="${next.name}">Next</a>`,
         `<a href="${C.JS_DISABLED_DIRECTORY}/index.html" data-random="track-in-album" id="random-button">${currentTrack ? 'Random' : 'Random Track'}</a>`
-    ].filter(Boolean).join(', ')})`;
+    ];
+
+    if (previousLine || nextLine) {
+        return `(${[previousLine, nextLine].filter(Boolean).join(', ')}<span class="js-hide">, ${randomLine}</span>)`;
+    } else {
+        return `<span class="js-hide">(${randomLine})</span>`;
+    }
 }
 
 function generateAlbumChronologyLinks(album, currentTrack = null) {