Reduce freezes on large playlists

This commit is contained in:
Calvin Montgomery 2013-06-24 22:45:44 -04:00
parent 5389d2827c
commit 7e356f38a8
2 changed files with 18 additions and 3 deletions

View file

@ -40,6 +40,7 @@ if($("#ytapiplayer").length > 0) {
var VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16);
}
var POSITION = -1;
var REBUILDING = false;
var socket = {
emit: function() {
console.log("socket not initialized");

View file

@ -291,9 +291,23 @@ function addQueueButtons(li) {
}
function rebuildPlaylist() {
$("#queue li").each(function() {
$(this).find(".btn-group").remove();
addQueueButtons($(this));
if(REBUILDING)
return;
REBUILDING = true;
var i = 0;
var qli = $("#queue li");
qli.each(function() {
var li = $(this);
setTimeout(function() {
addQueueButtons(li);
}, 10*i);
if(i == qli.length - 1) {
setTimeout(function() {
REBUILDING = false;
}, 10*i);
}
i++;
});
}