From: Mike Frysinger <vapier@gentoo.org>
Date: Sun, 1 Sep 2013 20:16:51 +0000 (-0400)
Subject: playlist: fix display, and let people delete items
X-Git-Tag: v3.0~2
X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=9cb957ede33364c6ba1b19529050a24cd2aa8f5f;p=chrome-ext%2Fmusic-player-client.git

playlist: fix display, and let people delete items
---

diff --git a/main.html b/main.html
index 90e2182..87add75 100644
--- a/main.html
+++ b/main.html
@@ -36,11 +36,18 @@ table.tabs td.selected {
 	background-color: white;
 }
 
+/* Playlist styles */
 table#playlist td {
 	border-left: black solid 1px;
 	padding-right: 0.5em;
 }
 
+td#playlist_del {
+	padding-left: 0.3em;
+	padding-right: 0.2em;
+	font-weight: bold;
+}
+
 /* Get the tabs to float at the bottom */
 html, body {
 	height: 100%;
@@ -58,6 +65,10 @@ div#footer {
 	height: 1.3em;
 	clear: both;
 }
+table#playlist {
+	height: 85px;
+	display: block;
+};
 </style>
 </head>
 
diff --git a/main.js b/main.js
index aa4c7bd..9902b93 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,11 @@ function pretty_time(time) {
 	return ret + ("00" + sec).substr(-2);
 }
 
+function playlist_del() {
+	mpc.deleteid(this.title);
+	this.parentNode.remove();
+}
+
 function update_ui(state, cmd) {
 	if (typeof(state) == 'string') {
 		ui_mpc_status.innerText = ({
@@ -314,6 +320,12 @@ function update_ui(state, cmd) {
 		if (song.Pos == currentsong.Pos)
 			row.style.fontWeight = 'bold';
 
+		cell = row.insertCell(-1);
+		cell.id = 'playlist_del';
+		cell.innerHTML = '&#164;';
+		cell.title = song.Id;
+		cell.onclick = playlist_del;
+
 		cell = row.insertCell(-1);
 		cell.innerText = song.Pos;
 		cell.style.textAlign = 'right';