Add plist_entry table row class hvmpd
authorHugo Villeneuve <hugo@hugovil.com>
Fri, 6 Jan 2023 22:36:29 +0000 (17:36 -0500)
committerHugo Villeneuve <hugo@hugovil.com>
Sat, 7 Jan 2023 00:33:26 +0000 (19:33 -0500)
htdocs/js/mpd.js
src/mpd_client.c

index cc22913..2f9cd2f 100644 (file)
@@ -588,7 +588,20 @@ function webSocketConnect() {
                                         '</td><td></td></tr>'
                                 );
                                 break;
-                            case 'wrap':
+                            case 'plist_entry':
+                                var clazz = 'plist_entry';
+                                $('#salamisandwich > tbody').append(
+                                    '<tr uri="' +
+                                        encodeURIComponent(obj.data[item].uri) +
+                                        '" class="' + clazz + '">' +
+                                        '<td><span class="glyphicon glyphicon-music"></span></td>' +
+                                        '<td colspan="5">' +
+                                        obj.data[item].title +
+                                        '</td>' +
+                                        '</tr>'
+                                );
+                                break;
+                        case 'wrap':
                                 if (current_app == 'browse') {
                                     $('#next').removeClass('hide');
                                 } else {
@@ -658,6 +671,13 @@ function webSocketConnect() {
                             'MPD_API_ADD_PLAY_TRACK',
                             'play'
                         );
+                        appendClickableIcon(
+                            $(
+                                '#salamisandwich > tbody > tr.plist_entry > td:last-child'
+                            ),
+                            'MPD_API_ADD_PLAY_TRACK',
+                            'play'
+                        );
                     } else {
                         $('#salamisandwich > tbody > tr').on({
                             mouseenter: function () {
@@ -673,6 +693,12 @@ function webSocketConnect() {
                                         'MPD_API_ADD_PLAY_TRACK',
                                         'play'
                                     );
+                                else if ($(this).is('.plist_entry'))
+                                    appendClickableIcon(
+                                        $(this).children().last(),
+                                        'MPD_API_ADD_PLAY_TRACK',
+                                        'play'
+                                    );
                             },
                             mouseleave: function () {
                                 $(this)
index 522199d..586f4f2 100644 (file)
@@ -830,7 +830,7 @@ int mpd_put_playlist(char *buffer, char *pl_name, unsigned int offset) {
 
             case MPD_ENTITY_TYPE_SONG:
                 song = mpd_entity_get_song(entity);
-                cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"song\",\"uri\":");
+                cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"plist_entry\",\"uri\":");
                 cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(song));
                 cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
                 cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));