« get me outta code hell

next/previous buttons in track header - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/upd8.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2020-06-03 16:37:19 -0300
committerFlorrie <towerofnix@gmail.com>2020-06-03 16:37:37 -0300
commitb21e5b5521cad7f38b93e2f41bf5d3c30eb8298c (patch)
treee8d68fa91755fd63854693e6c561380e40d8c22a /upd8.js
parenta9334c430b9c2b69f0d1d2eba976043b486fab11 (diff)
next/previous buttons in track header
Diffstat (limited to 'upd8.js')
-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, {