summaryrefslogtreecommitdiff
path: root/static/playlist.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/playlist.js')
-rw-r--r--static/playlist.js68
1 files changed, 55 insertions, 13 deletions
diff --git a/static/playlist.js b/static/playlist.js
index e5513d1..3590f2c 100644
--- a/static/playlist.js
+++ b/static/playlist.js
@@ -8,7 +8,7 @@ function Playlist(pl, audio) {
var li = this.pl.getElementsByTagName('li')[0];
while(li) {
var as = li.getElementsByTagName('a');
- if(as.length > 0) {
+ if(as.length == 2) {
var a = as[0];
if(a.ml.path == path && (!track || a.ml.track == track))
return li;
@@ -20,6 +20,7 @@ function Playlist(pl, audio) {
this.add = function(ml) {
var a = document.createElement('a');
+ a.setAttribute('class', 'song');
a.setAttribute('href', '#');
var name = ml.get_text();
a.appendChild(document.createTextNode(name));
@@ -36,7 +37,7 @@ function Playlist(pl, audio) {
li.previousElementSibling.previousElementSibling.parentElement.removeChild(li.previousElementSibling.previousElementSibling);
if(li.previousElementSibling && pl.pl.firstChild != li.previousElementSibling)
pl.pl.removeChild(pl.pl.firstChild);
- a.setAttribute('class', 'playing');
+ a.setAttribute('class', 'song playing');
pl.current = li;
ml.play();
@@ -59,11 +60,43 @@ function Playlist(pl, audio) {
album_li.appendChild(document.createTextNode(ml.metadata.album));
album_li.setAttribute('class', 'album');
+ var a_del = document.createElement('a');
+ a_del.setAttribute('class', 'delete');
+ a_del.setAttribute('href', '#');
+ a_del.setAttribute('title', 'Remove');
+ var del_img = new Image();
+ del_img.src = '/static/icons/delete.png';
+ a_del.appendChild(del_img);
+ a_del.onclick = (function(album_li) {
+ return function() {
+ while(album_li.nextElementSibling && album_li.nextElementSibling.getAttribute('class') != 'album')
+ pl.pl.removeChild(album_li.nextElementSibling);
+ pl.pl.removeChild(album_li);
+ return false;
+ }
+ })(album_li);
+
+ var span = document.createElement('span');
+ span.style.display = 'none';
+
+ album_li.onmouseover = (function(span) {
+ return function() {
+ span.style.display = '';
+ }
+ })(span);
+ album_li.onmouseout = (function(span) {
+ return function() {
+ span.style.display = 'none';
+ }
+ })(span);
+ span.appendChild(a_del);
+ album_li.appendChild(span);
+
this.pl.appendChild(album_li);
this.lastalbum = ml.metadata.album;
}
- var span = document.createElement('div');
+ var div = document.createElement('div');
// anchor to remove track from playlist
var a_del = document.createElement('a');
@@ -92,20 +125,29 @@ function Playlist(pl, audio) {
return false;
}
- a_del.hidden = true;
+ var span = document.createElement('span');
+ span.style.display = 'none';
- span.onmouseover = function() {
- a_del.hidden = false;
- }
- span.onmouseout = function() {
- a_del.hidden = true;
- }
+ div.onmouseover = (function(span) {
+ return function() {
+ span.style.display = '';
+ }
+ })(span);
+ div.onmouseout = (function(span) {
+ return function() {
+ span.style.display = 'none';
+ }
+ })(span);
+
+ div.appendChild(a);
+ div.appendChild(document.createTextNode(' '));
- span.appendChild(a);
- span.appendChild(document.createTextNode(' '));
span.appendChild(a_del);
+ span.setAttribute('class', 'right');
+
+ div.appendChild(span);
- li.appendChild(span);
+ li.appendChild(div);
this.pl.appendChild(li);
if(this.get_next() == li)