X-Git-Url: https://git.wh0rd.org/?p=chrome-ext%2Fmusic-player-client.git;a=blobdiff_plain;f=main.js;h=26d0bc7ae4bd7eb1ceb5ff5375500b3e4a051a18;hp=aa4c7bd961f329b5506724635ae7e4c7b6b72908;hb=17ac93ed65c5212d5cf6ecbac17b718738d82c00;hpb=ee26ebe43d89016c3014e030041e363e337f4ff5 diff --git a/main.js b/main.js index aa4c7bd..26d0bc7 100644 --- 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;