This commit is contained in:
Calvin Montgomery 2013-06-26 22:44:48 -04:00
parent c00b95feae
commit ab7ad2c36c
3 changed files with 30 additions and 12 deletions

View file

@ -650,7 +650,7 @@ Callbacks = {
queue: function(data) { queue: function(data) {
// Wait until pending movements are completed // Wait until pending movements are completed
if(MOVING) { if(PL_MOVING || PL_ADDING || PL_DELETING) {
setTimeout(function() { setTimeout(function() {
Callbacks.queue(data); Callbacks.queue(data);
}, 100); }, 100);
@ -699,11 +699,25 @@ Callbacks = {
}, },
"delete": function(data) { "delete": function(data) {
// Wait until any pending manipulation is finished
if(PL_MOVING || PL_ADDING || PL_DELETING) {
setTimeout(function() {
Callbacks["delete"](data);
}, 100);
return;
}
var li = $("#queue").children()[data.position]; var li = $("#queue").children()[data.position];
$(li).remove(); $(li).remove();
}, },
moveVideo: function(data) { moveVideo: function(data) {
// Wait until any pending manipulation is finished
if(PL_MOVING || PL_ADDING || PL_DELETING) {
setTimeout(function() {
Callbacks.moveVideo(position);
}, 100);
return;
}
if(data.from < POSITION && data.to >= POSITION) if(data.from < POSITION && data.to >= POSITION)
POSITION--; POSITION--;
else if(data.from > POSITION && data.to <= POSITION) else if(data.from > POSITION && data.to <= POSITION)
@ -715,10 +729,10 @@ Callbacks = {
}, },
setPosition: function(position) { setPosition: function(position) {
// Wait until any pending movement is finished // Wait until any pending manipulation is finished
if(MOVING) { if(PL_MOVING || PL_ADDING || PL_DELETING) {
setTimeout(function() { setTimeout(function() {
Callbacks.move(position); Callbacks.setPosition(position);
}, 100); }, 100);
return; return;
} }

View file

@ -40,7 +40,9 @@ 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 MOVING = false; var PL_MOVING = false;
var PL_ADDING = false;
var PL_DELETING = false;
var REBUILDING = false; var REBUILDING = false;
var socket = { var socket = {
emit: function() { emit: function() {

View file

@ -259,8 +259,9 @@ function addQueueButtons(li) {
} }
// Temp/Untemp // Temp/Untemp
if(hasPermission("settemp")) { if(hasPermission("settemp")) {
var tempstr = li.data("media").temp?"Make Permanent":"Make Temporary";
$("<button/>").addClass("btn btn-mini qbtn-tmp") $("<button/>").addClass("btn btn-mini qbtn-tmp")
.html("<i class='icon-flag'></i>Make Temporary") .html("<i class='icon-flag'></i>" + tempstr)
.click(function() { .click(function() {
var i = $("#queue").children().index(li); var i = $("#queue").children().index(li);
var temp = li.find(".qbtn-tmp").data("temp"); var temp = li.find(".qbtn-tmp").data("temp");
@ -313,24 +314,25 @@ function addQueueButtons(li) {
} }
function rebuildPlaylist() { function rebuildPlaylist() {
if(REBUILDING)
return;
var qli = $("#queue li"); var qli = $("#queue li");
if(qli.length == 0) if(qli.length == 0)
return; return;
REBUILDING = true; REBUILDING = Math.random() + "";
var r = REBUILDING;
var i = 0; var i = 0;
qli.each(function() { qli.each(function() {
var li = $(this); var li = $(this);
(function(i) { (function(i, r) {
setTimeout(function() { setTimeout(function() {
// Stop if another rebuild is running
if(REBUILDING != r)
return;
addQueueButtons(li); addQueueButtons(li);
if(i == qli.length - 1) { if(i == qli.length - 1) {
REBUILDING = false; REBUILDING = false;
} }
}, 10*i); }, 10*i);
})(i); })(i, r);
i++; i++;
}); });
} }