Getting there

This commit is contained in:
calzoneman 2013-07-03 11:26:10 -04:00
parent fc5034d26a
commit f6b02a166a
4 changed files with 134 additions and 41 deletions

View file

@ -649,28 +649,35 @@ Callbacks = {
},
queue: function(data) {
var li = makeQueueEntry(data.item, true);
li.hide();
var q = $("#queue");
li.attr("title", data.item.queueby
? ("Added by: " + data.item.queueby)
: "Added by: Unknown");
if(data.after === "prepend") {
li.prependTo(q);
li.show("blind");
return;
}
else if(data.after === "append") {
li.appendTo(q);
li.show("blind");
}
else {
var liafter = $(".pluid-" + data.after);
if(liafter.length == 0)
return false;
li.insertAfter(liafter);
li.show("blind");
}
queueAction({
fn: function () {
var li = makeQueueEntry(data.item, true);
li.hide();
var q = $("#queue");
li.attr("title", data.item.queueby
? ("Added by: " + data.item.queueby)
: "Added by: Unknown");
if(data.after === "prepend") {
li.prependTo(q);
li.show("blind");
return true;
}
else if(data.after === "append") {
li.appendTo(q);
li.show("blind");
return true;
}
else {
var liafter = playlistFind(data.after);
if(!liafter) {
return false;
}
li.insertAfter(liafter);
li.show("blind");
return true;
}
}
});
},
queueFail: function(data) {
@ -707,30 +714,43 @@ Callbacks = {
},
"delete": function(data) {
var li = $(".pluid-" + data.uid);
li.hide("blind", function() {
li.remove();
queueAction({
fn: function () {
var li = $(".pluid-" + data.uid);
li.hide("blind", function() {
li.remove();
});
}
});
},
moveVideo: function(data) {
if(data.moveby != CLIENT.name)
playlistMove(data.from, data.after);
if(data.moveby != CLIENT.name) {
queueAction({
fn: function () {
playlistMove(data.from, data.after);
}
});
}
},
setCurrent: function(uid) {
PL_CURRENT = uid;
var qli = $("#queue li");
qli.removeClass("queue_active");
var li = $(".pluid-" + uid);
if(li.length == 0) {
return false;
}
queueAction({
fn: function () {
PL_CURRENT = uid;
var qli = $("#queue li");
qli.removeClass("queue_active");
var li = $(".pluid-" + uid);
if(li.length == 0) {
return false;
}
li.addClass("queue_active");
$("#queue").scrollTop(0);
var scroll = li.position().top - $("#queue").position().top;
$("#queue").scrollTop(scroll);
li.addClass("queue_active");
$("#queue").scrollTop(0);
var scroll = li.position().top - $("#queue").position().top;
$("#queue").scrollTop(scroll);
}
});
},
changeMedia: function(data) {

View file

@ -968,6 +968,40 @@ function addLibraryButtons(li, id, type) {
/* queue stuff */
var PL_QUEUED_ACTIONS = [];
var PL_ACTION_INTERVAL = false;
function queueAction(data) {
PL_QUEUED_ACTIONS.push(data);
if(PL_ACTION_INTERVAL)
return;
PL_ACTION_INTERVAL = setInterval(function () {
var data = PL_QUEUED_ACTIONS.shift();
if(!("expire" in data))
data.expire = Date.now() + 5000;
if(!data.fn()) {
if(Date.now() < data.expire)
PL_QUEUED_ACTIONS.unshift(data);
}
if(PL_QUEUED_ACTIONS.length == 0) {
clearInterval(PL_ACTION_INTERVAL);
PL_ACTION_INTERVAL = false;
}
}, 100);
}
// Because jQuery UI does weird things
function playlistFind(uid) {
var children = document.getElementById("queue").children;
for(var i in children) {
if(typeof children[i].getAttribute != "function")
continue;
if(children[i].getAttribute("class").indexOf("pluid-" + uid) != -1)
return children[i];
}
return false;
}
function playlistMove(from, after) {
var lifrom = $(".pluid-" + from);
if(lifrom.length == 0)