Commit f83a3793 authored by P. J. McDermott's avatar P. J. McDermott

Catch a possible TypeError in the web player.

For example, when clicking the "Skip Forwards" button while there are no
more songs in the playlist, the error in loadSong() propagates up the
call stack to the HTML level, the "return false;" in the "onclick"
attribute value is ignored, and the hyperlink to "#" is followed.
parent fc83349f
......@@ -253,11 +253,16 @@ function playSong(song) {
* @param int song The song number in the playlist that should be loaded
*/
function loadSong(song) {
var url = playlist[song]["url"];
artist = playlist[song]["artist"];
album = playlist[song]["album"];
track = playlist[song]["track"];
trackpage = playlist[song]["trackpage"];
try {
var url = playlist[song]["url"];
artist = playlist[song]["artist"];
album = playlist[song]["album"];
track = playlist[song]["track"];
trackpage = playlist[song]["trackpage"];
} catch (e) {
// Handle a possible TypeError when song < 0 or song >= playlist.length
return;
}
// Highlight current song in the playlist
$("#song-" + current_song).css({fontWeight : "normal"});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment