Rearranged artist and album information in queue and search results.
authoreb041592 <35889760+eb041592@users.noreply.github.com>
Sat, 3 Feb 2018 11:03:33 +0000 (12:03 +0100)
committereb041592 <35889760+eb041592@users.noreply.github.com>
Sat, 3 Feb 2018 11:03:33 +0000 (12:03 +0100)
htdocs/css/mpd.css
htdocs/index.html
htdocs/js/mpd.js
src/mpd_client.c

index 647bfc7..88987e2 100644 (file)
@@ -55,10 +55,15 @@ body {
   }
 }
 
-#salamisandwich td:nth-child(3), th:nth-child(3) {
+#salamisandwich td:nth-last-child(2), th:nth-last-child(2) {
   text-align: right;
 }
 
+#salamisandwich td:nth-child(2) span {
+       font-style:italic;
+       font-size:90%;
+}
+
 tbody {
   cursor: pointer;
 }
index d74dc67..726d193 100644 (file)
             <thead>
               <tr>
                 <th>#</th>
-                <th>Title</th>
+                <th colspan="2">Track</th>
                 <th>Duration</th>
                 <th></th>
               </tr>
index ef760bf..6c8841a 100644 (file)
@@ -238,7 +238,8 @@ function webSocketConnect() {
 
                         $('#salamisandwich > tbody').append(
                             "<tr trackid=\"" + obj.data[song].id + "\"><td>" + (obj.data[song].pos + 1) + "</td>" +
-                                "<td>" + obj.data[song].artist + " [" + obj.data[song].album  + "] - " + obj.data[song].title  + "</td>" +
+                                "<td>" + obj.data[song].artist + "<br /><span>" + obj.data[song].album  + "</span></td>" +
+                                "<td>" + obj.data[song].title  + "</td>" +
                                 "<td>" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
                         "</td><td></td></tr>");
                     }
@@ -334,7 +335,7 @@ function webSocketConnect() {
                                 $('#salamisandwich > tbody').append(
                                     "<tr uri=\"" + encodeURI(obj.data[item].dir) + "\" class=\"" + clazz + "\">" +
                                     "<td><span class=\"glyphicon glyphicon-folder-open\"></span></td>" +
-                                    "<td><a>" + basename(obj.data[item].dir) + "</a></td>" +
+                                    "<td colspan=\"2\"><a>" + basename(obj.data[item].dir) + "</a></td>" +
                                     "<td></td><td></td></tr>"
                                 );
                                 break;
@@ -346,7 +347,7 @@ function webSocketConnect() {
                                 $('#salamisandwich > tbody').append(
                                     "<tr uri=\"" + encodeURI(obj.data[item].plist) + "\" class=\"" + clazz + "\">" +
                                     "<td><span class=\"glyphicon glyphicon-list\"></span></td>" +
-                                    "<td><a>" + basename(obj.data[item].plist) + "</a></td>" +
+                                    "<td colspan=\"2\"><a>" + basename(obj.data[item].plist) + "</a></td>" +
                                     "<td></td><td></td></tr>"
                                 );
                                 break;
@@ -354,10 +355,15 @@ function webSocketConnect() {
                                 var minutes = Math.floor(obj.data[item].duration / 60);
                                 var seconds = obj.data[item].duration - minutes * 60;
 
+                                if (typeof obj.data[item].artist === 'undefined') {
+                                    var details = "<td colspan=\"2\">" + obj.data[item].title + "</td>";
+                                } else {
+                                    var details = "<td>" + obj.data[item].artist + "<br /><span>" + obj.data[item].album + "</span></td><td>" + obj.data[item].title + "</td>";
+                                }
+
                                $('#salamisandwich > tbody').append(
                                     "<tr uri=\"" + encodeURI(obj.data[item].uri) + "\" class=\"song\">" +
-                                    "<td><span class=\"glyphicon glyphicon-music\"></span></td>" +
-                                    "<td>" + (typeof obj.data[item].artist !== 'undefined' ? obj.data[item].artist + " [" + obj.data[item].album + "] - " : '') + obj.data[item].title + "</td>" +
+                                    "<td><span class=\"glyphicon glyphicon-music\"></span></td>" + details +
                                     "<td>" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
                                     "</td><td></td></tr>"
                                 );
@@ -367,8 +373,8 @@ function webSocketConnect() {
                                     $('#next').removeClass('hide');
                                 } else {
                                     $('#salamisandwich > tbody').append(
-                                        "<tr><td><span class=\"glyphicon glyphicon-remove\"></span></td>" + 
-                                        "<td>Too many results, please refine your search!</td>" + 
+                                        "<tr><td><span class=\"glyphicon glyphicon-remove\"></span></td>" +
+                                        "<td colspan=\"2\">Too many results, please refine your search!</td>" +
                                         "<td></td><td></td></tr>"
                                     );
                                 }
index 099f673..1054ede 100644 (file)
@@ -480,8 +480,11 @@ char* mpd_get_artist(struct mpd_song const *song)
     char *str;
 
     str = (char *)mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);
-
-    return str;
+    if (str == NULL) {
+       return "";
+    } else {
+       return str;
+    }
 }
 
 char* mpd_get_album(struct mpd_song const *song)
@@ -489,8 +492,11 @@ char* mpd_get_album(struct mpd_song const *song)
     char *str;
 
     str = (char *)mpd_song_get_tag(song, MPD_TAG_ALBUM, 0);
-
-    return str;
+    if (str == NULL) {
+       return "";
+    } else {
+       return str;
+    }
 }
 
 int mpd_put_state(char *buffer, int *current_song_id, unsigned *queue_version)