summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-08-23 14:08:02 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-08-23 14:08:02 +0200
commitd4394a532978e34176b886048b2f9f263b9fdcbb (patch)
treeb5491815d3428f736683fa417e8d35b6c6bb0e64
parent2c49a03494ec2cebf2c820efb257c950f170face (diff)
Improved client recode logic.
-rw-r--r--static/playlist.js32
1 files changed, 27 insertions, 5 deletions
diff --git a/static/playlist.js b/static/playlist.js
index 44b72ae..e5513d1 100644
--- a/static/playlist.js
+++ b/static/playlist.js
@@ -47,9 +47,6 @@ function Playlist(pl, audio) {
nextsong = nextsong.nextElementSibling;
if(nextsong) {
var nexta = nextsong.getElementsByTagName('a')[0];
- log('nexta: ' + nexta);
- log(nexta.onclick);
- log('next ml: ' + nexta.ml);
nexta.ml.recode();
}
@@ -79,12 +76,20 @@ function Playlist(pl, audio) {
a_del.onclick = function() {
log(li.previousElementSibling);
log(li.nextElementSibling);
+ // remove previous element if it is an album header and we're at end of queue,
+ // or next element is an album header
if(li.previousElementSibling && li.previousElementSibling.getAttribute('class') == 'album'
&& (!li.nextElementSibling || li.nextElementSibling.getAttribute('class') == 'album'))
pl.pl.removeChild(li.previousElementSibling);
pl.pl.removeChild(li);
if(pl.pl.childElementCount == 0)
pl.lastalbum = null;
+
+ // recode next
+ var next = pl.get_next();
+ if(next)
+ next.getElementsByTagName('a')[0].ml.recode();
+
return false;
}
a_del.hidden = true;
@@ -103,11 +108,28 @@ function Playlist(pl, audio) {
li.appendChild(span);
this.pl.appendChild(li);
- if(this.pl.firstChild == li || (this.current && this.current.nextElementSibling == li)
- || (this.pl.firstChild.getAttribute('class') == 'album' && this.pl.firstChild.nextElementSibling == li))
+ if(this.get_next() == li)
ml.recode();
}
+ // get the next queued song
+ this.get_next = function() {
+ var next = null;
+ if(this.current)
+ next = this.current.nextElementSibling;
+ else if(this.pl.firstChild)
+ next = this.pl.firstChild;
+
+ if(!next)
+ return null;
+
+ if(next.getAttribute('class') == 'album')
+ next = next.nextElementSibling;
+
+ return next;
+ }
+
+ // play the next queued song
this.next = function() {
log('next');
log('this: ' + this);