]> git.wh0rd.org Git - chrome-ext/music-player-client.git/commitdiff
playlist: add ability to play an item
authorMike Frysinger <vapier@gentoo.org>
Sun, 1 Sep 2013 20:32:30 +0000 (16:32 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sun, 1 Sep 2013 20:32:30 +0000 (16:32 -0400)
main.js

diff --git a/main.js b/main.js
index 9902b935d01e7042570268c13be9d07b82f337c1..26d0bc7ae4bd7eb1ceb5ff5375500b3e4a051a18 100644 (file)
--- a/main.js
+++ b/main.js
@@ -274,10 +274,15 @@ function pretty_time(time) {
 }
 
 function playlist_del() {
-       mpc.deleteid(this.title);
+       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 = ({
@@ -323,12 +328,16 @@ function update_ui(state, cmd) {
                cell = row.insertCell(-1);
                cell.id = 'playlist_del';
                cell.innerHTML = '&#164;';
-               cell.title = song.Id;
+               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;