From acb5136c151db0a7c051eb4d7f9c4097c8c88943 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Tue, 1 Oct 2013 13:25:05 -0500 Subject: [PATCH] Improve setCurrent --- www/assets/js/callbacks.js | 43 +++++++++++++++----------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index f342ed24..840749a7 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -767,24 +767,24 @@ Callbacks = { queueAction({ fn: function () { var li = makeQueueEntry(data.item, true); + if (data.item.uid === PL_CURRENT) + li.addClass("queue_active"); li.hide(); var q = $("#queue"); li.attr("title", data.item.queueby ? ("Added by: " + data.item.queueby) : "Added by: Unknown"); - if(data.after === "prepend") { + if (data.after === "prepend") { li.prependTo(q); li.show("blind"); return true; - } - else if(data.after === "append") { + } else if (data.after === "append") { li.appendTo(q); li.show("blind"); return true; - } - else { + } else { var liafter = playlistFind(data.after); - if(!liafter) { + if (!liafter) { return false; } li.insertAfter(liafter); @@ -873,27 +873,18 @@ Callbacks = { }, setCurrent: function(uid) { - queueAction({ - fn: function () { - PL_CURRENT = uid; - var qli = $("#queue li"); - qli.removeClass("queue_active"); - var li = $(".pluid-" + uid); - if(li.length == 0) { - return false; + PL_CURRENT = uid; + $("#queue li").removeClass("queue_active"); + var li = $(".pluid-" + uid); + if (li.length !== 0) { + li.addClass("queue_active"); + var tmr = setInterval(function () { + if (!PL_WAIT_SCROLL) { + scrollQueue(); + clearInterval(tmr); } - - li.addClass("queue_active"); - var timer = setInterval(function () { - if(!PL_WAIT_SCROLL) { - scrollQueue(); - clearInterval(timer); - } - }, 100); - return true; - }, - can_wait: true - }); + }, 100); + } }, changeMedia: function(data) {