Jelajahi Sumber

Rearranged artist and album information in queue and search results.

eb041592 6 tahun lalu
induk
melakukan
fe0277bfbe
4 mengubah file dengan 30 tambahan dan 13 penghapusan
  1. 6 1
      htdocs/css/mpd.css
  2. 1 1
      htdocs/index.html
  3. 13 7
      htdocs/js/mpd.js
  4. 10 4
      src/mpd_client.c

+ 6 - 1
htdocs/css/mpd.css

@@ -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;
 }

+ 1 - 1
htdocs/index.html

@@ -114,7 +114,7 @@
             <thead>
               <tr>
                 <th>#</th>
-                <th>Title</th>
+                <th colspan="2">Track</th>
                 <th>Duration</th>
                 <th></th>
               </tr>

+ 13 - 7
htdocs/js/mpd.js

@@ -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>"
                                     );
                                 }

+ 10 - 4
src/mpd_client.c

@@ -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)