diff --git a/htdocs/index.html b/htdocs/index.html index 737802f..066029a 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -188,6 +188,21 @@
+
+ + + +
+
-
- -
+
+ +
diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js index c8782f7..b6e7644 100644 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@ -303,20 +303,32 @@ function webSocketConnect() { if ( isTouch ) { $('#salamisandwich > tbody > tr > td:last-child').append( "" + + "onclick=\"trash($(this).parents('tr'));\">" + ""); } else { $('#salamisandwich > tbody > tr').on({ mouseover: function(){ + var doomed = $(this); + if ( $('#btntrashmodeup').hasClass('active') ) + doomed = $("#salamisandwich > tbody > tr:lt(" + ($(this).index() + 1) + ")"); + if ( $('#btntrashmodedown').hasClass('active') ) + doomed = $("#salamisandwich > tbody > tr:gt(" + ($(this).index() - 1) + ")"); + $.each(doomed, function(){ if($(this).children().last().has("a").length == 0) $(this).children().last().append( "" + + "onclick=\"trash($(this).parents('tr'));\">" + "") .find('a').fadeTo('fast',1); + }); }, mouseleave: function(){ - $(this).children().last().find("a").stop().remove(); + var doomed = $(this); + if ( $('#btntrashmodeup').hasClass('active') ) + doomed = $("#salamisandwich > tbody > tr:lt(" + ($(this).index() + 1) + ")"); + if ( $('#btntrashmodedown').hasClass('active') ) + doomed = $("#salamisandwich > tbody > tr:gt(" + ($(this).index() - 1) + ")"); + $.each(doomed, function(){$(this).children().last().find("a").stop().remove();}); } }); }; @@ -757,6 +769,19 @@ function setLocalStream(mpdhost) { $("#mpdstream").change(); } +function trash(tr) { + if ( $('#btntrashmodeup').hasClass('active') ) { + socket.send('MPD_API_RM_RANGE,0,' + (tr.index() + 1)); + tr.remove(); + } else if ( $('#btntrashmodesingle').hasClass('active') ) { + socket.send('MPD_API_RM_TRACK,' + tr.attr('trackid')); + tr.remove(); + } else if ( $('#btntrashmodedown').hasClass('active') ) { + socket.send('MPD_API_RM_RANGE,' + tr.index() + ',-1'); + tr.remove(); + }; +} + function basename(path) { return path.split('/').reverse()[0]; } @@ -791,6 +816,11 @@ function toggleoutput(button, id) { socket.send("MPD_API_TOGGLE_OUTPUT,"+id+"," + ($(button).hasClass('active') ? 0 : 1)); } +$('#trashmode').children("button").on('click', function(e) { + $('#trashmode').children("button").removeClass("active"); + $(this).addClass("active"); +}); + $('#btnnotify').on('click', function (e) { if($.cookie("notification") === "true") { $.cookie("notification", false); @@ -866,7 +896,7 @@ $('.page-btn').on('click', function (e) { function addStream() { if($('#streamurl').val().length > 0) { - socket.send('MPD_API_ADD_TRACK,'+$('#streamurl').val()); + socket.send('MPD_API_ADD_TRACK,'+$('#streamurl').val()); } $('#streamurl').val(""); $('#addstream').modal('hide'); @@ -874,7 +904,7 @@ function addStream() { function saveQueue() { if($('#playlistname').val().length > 0) { - socket.send('MPD_API_SAVE_QUEUE,'+$('#playlistname').val()); + socket.send('MPD_API_SAVE_QUEUE,'+$('#playlistname').val()); } $('#savequeue').modal('hide'); } @@ -927,7 +957,7 @@ function songNotify(title, artist, album) { if(typeof album != 'undefined' && album.length > 0) textNotification += "\n " + album; - var notification = new Notification(title, {icon: 'assets/favicon.ico', body: textNotification}); + var notification = new Notification(title, {icon: 'assets/favicon.ico', body: textNotification}); setTimeout(function(notification) { notification.close(); }, 3000, notification); diff --git a/src/mpd_client.c b/src/mpd_client.c index eac06c1..701cc5f 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -94,6 +94,10 @@ int callback_mpd(struct mg_connection *c) if(sscanf(c->content, "MPD_API_RM_TRACK,%u", &uint_buf)) mpd_run_delete_id(mpd.conn, uint_buf); break; + case MPD_API_RM_RANGE: + if(sscanf(c->content, "MPD_API_RM_RANGE,%u,%u", &uint_buf, &uint_buf_2)) + mpd_run_delete_range(mpd.conn, uint_buf, uint_buf_2); + break; case MPD_API_MOVE_TRACK: if (sscanf(c->content, "MPD_API_MOVE_TRACK,%u,%u", &uint_buf, &uint_buf_2) == 2) { diff --git a/src/mpd_client.h b/src/mpd_client.h index 9ab4360..951869d 100644 --- a/src/mpd_client.h +++ b/src/mpd_client.h @@ -46,6 +46,7 @@ X(MPD_API_PLAY_TRACK) \ X(MPD_API_SAVE_QUEUE) \ X(MPD_API_RM_TRACK) \ + X(MPD_API_RM_RANGE) \ X(MPD_API_RM_ALL) \ X(MPD_API_MOVE_TRACK) \ X(MPD_API_SEARCH) \