« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--upd8.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/upd8.js b/upd8.js
index bb5e22de..d22f1bee 100644
--- a/upd8.js
+++ b/upd8.js
@@ -1701,14 +1701,19 @@ function chronologyButtons(currentTrack, {
 }
 
 function generateHeaderForAlbum(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 fixWS`
         <h2>
             <a href="index.html">Home</a>
             / <a href="${C.ALBUM_DIRECTORY}/${album.directory}/index.html">${album.name}</a>
             ${currentTrack && `/ <a href="${C.TRACK_DIRECTORY}/${currentTrack.directory}/index.html">${currentTrack.name}</a>`}
-            <span>
-                ${album.tracks.length > 1 && `(<a href="${C.JS_DISABLED_DIRECTORY}/index.html" data-random="track-in-album">Random track</a>)`}
-            </span>
+            <span>${album.tracks.length > 1 && `(${[
+                previous && `<a href="${C.TRACK_DIRECTORY}/${previous.directory}/index.html" title="${previous.name}">Previous</a>`,
+                next && `<a href="${C.TRACK_DIRECTORY}/${next.directory}/index.html" title="${next.name}">Next</a>`,
+                `<a href="${C.JS_DISABLED_DIRECTORY}/index.html" data-random="track-in-album">${currentTrack ? 'Random' : 'Random Track'}</a>`
+            ].filter(Boolean).join(', ')})`}</span>
         </h2>
         <div>
             ${currentTrack === null && chronologyButtons(album, {