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

View file

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

View file

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