else/Javascript/playalbum.js
Ethan Dalool b4ca46a165 Add undefined to all bookmarklets for firefox compatibility.
On Firefox, clicking a bookmarklet will cause the page to display
the last return value of the bookmarklet, deleting the rest of the
page contents. The solution is to add undefined; at the end.
2020-08-12 13:54:09 -07:00

20 lines
649 B
JavaScript

javascript:
function give_event(player, index)
{
/*
This needs to be a function instead of inlined into the loop because `next`
needs to be scoped, otherwise all of the players share the same next
variable and it doesn't work.
*/
var next = index + 1;
players[index].addEventListener("ended", function(){ console.log(next); players[next].play(); });
}
players = document.getElementsByTagName("audio");
/*length - 1 because the final player doesn't need an event, only the second-last.*/
for (var index = 0; index < players.length - 1; index += 1)
{
give_event(players[index], index);
}
players[0].play();
undefined;