]> git.wh0rd.org - chrome-ext/music-player-client.git/blobdiff - main.js
playlist: add ability to play an item
[chrome-ext/music-player-client.git] / main.js
diff --git a/main.js b/main.js
index aa4c7bd961f329b5506724635ae7e4c7b6b72908..26d0bc7ae4bd7eb1ceb5ff5375500b3e4a051a18 100644 (file)
--- a/main.js
+++ b/main.js
@@ -110,6 +110,7 @@ function tramp_mpc_consume() {
        mpc.consume(val);
        setToggleButton(this, val);
 }
+function tramp_mpc_deleteid() { mpc.deleteid(this.title); }
 function tramp_mpc_next() { mpc.next(); }
 function tramp_mpc_pause() { mpc.pause(); }
 function tramp_mpc_play() { mpc.play(); }
@@ -272,6 +273,16 @@ function pretty_time(time) {
        return ret + ("00" + sec).substr(-2);
 }
 
+function playlist_del() {
+       mpc.deleteid(this.song_id);
+       this.parentNode.remove();
+}
+
+function playlist_play() {
+       mpc.playid(this.song_id);
+       this.parentNode.style.fontWeight = 'bold';
+}
+
 function update_ui(state, cmd) {
        if (typeof(state) == 'string') {
                ui_mpc_status.innerText = ({
@@ -314,9 +325,19 @@ function update_ui(state, cmd) {
                if (song.Pos == currentsong.Pos)
                        row.style.fontWeight = 'bold';
 
+               cell = row.insertCell(-1);
+               cell.id = 'playlist_del';
+               cell.innerHTML = '¤';
+               cell.song_id = song.Id;
+               cell.title = 'delete';
+               cell.onclick = playlist_del;
+
                cell = row.insertCell(-1);
                cell.innerText = song.Pos;
                cell.style.textAlign = 'right';
+               cell.song_id = song.Id;
+               cell.title = 'play';
+               cell.onclick = playlist_play;
 
                if ('Artist' in song) {
                        row.insertCell(-1).innerText = song.Artist;