diff options
| -rw-r--r-- | static/playlist.js | 32 | 
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); | 
