Merge branch 'delete'
authorSuperBFG7 <daniel@despite.ch>
Sat, 8 Apr 2017 09:31:41 +0000 (11:31 +0200)
committerSuperBFG7 <daniel@despite.ch>
Sat, 8 Apr 2017 09:31:41 +0000 (11:31 +0200)
1  2 
htdocs/index.html
htdocs/js/mpd.js
src/mpd_client.c
src/mpd_client.h

Simple merge
@@@ -701,62 -606,19 +713,75 @@@ function clickPlay() 
          socket.send('MPD_API_SET_PAUSE');
  }
  
 +function renumber_table(tableID,item) {
 +    was = item.children("td").first().text();//Check if first item exists!
 +    is = item.index() + 1;//maybe add pagination
 +
 +    if (was != is) {
 +        socket.send("MPD_API_MOVE_TRACK," + was + "," + is);
 +        socket.send('MPD_API_GET_QUEUE,'+pagination);
 +    }
 +}
 +
 +function clickLocalPlay() {
 +    var player = document.getElementById('player');
 +    $("#localplay-icon").removeClass("glyphicon-play").removeClass("glyphicon-pause");
 +      
 +
 +    if ( !$('#track-icon').hasClass('glyphicon-play') ) {
 +              clickPlay();
 +      }
 +
 +    if ( player.paused ) {
 +        var mpdstream = $.cookie("mpdstream");
 +
 +        if ( mpdstream ) {
 +            player.src = mpdstream;
 +            console.log("playing mpd stream: " + player.src);
 +            player.load();
 +            player.play();
 +            $("#localplay-icon").addClass("glyphicon-pause");
 +        } else {
 +            $("#mpdstream").change(function(){ clickLocalPlay(); $(this).unbind("change"); });
 +            $("#localplay-icon").addClass("glyphicon-play");
 +            getHost();
 +        }
 +    } else {
 +        player.pause();
 +    }
 +}
 +
 +function setLocalStream(mpdhost) {
 +    var mpdstream = $.cookie("mpdstream");
 +
 +    if ( !mpdstream ) {
 +        mpdstream = "http://";
 +        if ( mpdhost == "127.0.0.1" )
 +            mpdstream += window.location.hostname;
 +        else
 +            mpdstream += mpdhost;
 +        mpdstream += ":8000/";
 +
 +        $.cookie("mpdstream", mpdstream, { expires: 424242 });
 +    }
 +
 +    $("#mpdstream").val(mpdstream);
 +    $("#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];
  }
@@@ -94,14 -93,10 +94,18 @@@ int callback_mpd(struct mg_connection *
              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)
 +            {
 +                uint_buf -= 1;
 +                uint_buf_2 -= 1;
 +                mpd_run_move(mpd.conn, uint_buf, uint_buf_2);
 +            }
 +            break;
          case MPD_API_PLAY_TRACK:
              if(sscanf(c->content, "MPD_API_PLAY_TRACK,%u", &uint_buf))
                  mpd_run_play_id(mpd.conn, uint_buf);
      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) \
 +    X(MPD_API_SEND_MESSAGE) \
      X(MPD_API_SET_VOLUME) \
      X(MPD_API_SET_PAUSE) \
      X(MPD_API_SET_PLAY) \