diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js
index fd470401..39f97134 100644
--- a/www/assets/js/callbacks.js
+++ b/www/assets/js/callbacks.js
@@ -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;
}
diff --git a/www/assets/js/data.js b/www/assets/js/data.js
index 3b5070c9..53e81708 100644
--- a/www/assets/js/data.js
+++ b/www/assets/js/data.js
@@ -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() {
diff --git a/www/assets/js/util.js b/www/assets/js/util.js
index defcccc7..09d1acf2 100644
--- a/www/assets/js/util.js
+++ b/www/assets/js/util.js
@@ -259,8 +259,9 @@ function addQueueButtons(li) {
}
// Temp/Untemp
if(hasPermission("settemp")) {
+ var tempstr = li.data("media").temp?"Make Permanent":"Make Temporary";
$("").addClass("btn btn-mini qbtn-tmp")
- .html("Make Temporary")
+ .html("" + 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++;
});
}