The "problem" arises when my current session expires and I'm no longer authorized to grab the data that is retrieved on queue and history javascript calls. The existing code like this for updating the queue (interfaces/Plush/templates/static/javascripts/plush.js):
Code: Select all
function RefreshTheQueue() {
if (skipRefresh) return $('#skipped_refresh').fadeIn("slow").fadeOut("slow"); // set within queue <table>
var limit = queue_view_preference;
if ($('#queue_view_preference').val() != "")
var limit = $('#queue_view_preference').val()
$.ajax({
type: "GET",
url: 'queue/?dummy2='+limit+'&dummy='+Math.random(),
success: function(result){
return $('#queue').html(result);
}
});
}
Now I'm not all that familiar with jQuery (a Prototype man myself); but, I think there should be a manner to programmatically distinguish between http status codes when using jQuery's ajax. It's probably something like on401, 301, etc much like the success or onsuccess depending on your library.
If this is possible in jQuery and Plush+SABnzbd don't find itself throwing out 301 or 401 status codes often (shouldn't be): I suggest adding the additional anonymous functions to handle 301 and 401 status codes and handle them more appropriately. For 301 codes, Plush could redirect the client to that location (window.location.href i think?) and for 401 codes a friendly error msg should probably be displayed (otherwise i bet the standard "authentication required" message will appear in the queue and history's place). Another solution could be to provide an additional variable that can be set in SABnzbd (or Plush) for a redirection url if such codes occur, or even a URL to request regularly in order to keep sessions active.
I'll check into the feasibility of this in jQuery later, and maybe I'll check into this other post as well while I'm at it ?topic=677