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 VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16);
} }
var POSITION = -1; var POSITION = -1;
var REBUILDING = false;
var socket = { var socket = {
emit: function() { emit: function() {
console.log("socket not initialized"); console.log("socket not initialized");

View file

@ -291,9 +291,23 @@ function addQueueButtons(li) {
} }
function rebuildPlaylist() { function rebuildPlaylist() {
$("#queue li").each(function() { if(REBUILDING)
$(this).find(".btn-group").remove(); return;
addQueueButtons($(this));
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++;
}); });
} }