Browse Source

plush | javascript simplification (doesn't look like the 3 queue sorts work)

tags/0.6.0
pairofdimes 17 years ago
parent
commit
bd3567b209
  1. 6
      main/interfaces/Plush/templates/queue.tmpl
  2. 122
      main/interfaces/Plush/templates/static/javascripts/main.js

6
main/interfaces/Plush/templates/queue.tmpl

@ -54,20 +54,20 @@
<option value="-1" <!--#if $slot.priority == "Low" then "selected" else ""#-->>Low</option> <option value="-1" <!--#if $slot.priority == "Low" then "selected" else ""#-->>Low</option>
</select> </select>
<!--#if $cat_list#--> <!--#if $cat_list#-->
<select title="Category" class="proc_category"> <select title="Category" class="change_cat">
<!--#for $ct in $cat_list#--> <!--#for $ct in $cat_list#-->
<option value="$ct" <!--#if $slot.cat.lower() == $ct.lower() then "selected" else ""#-->>$ct</option> <option value="$ct" <!--#if $slot.cat.lower() == $ct.lower() then "selected" else ""#-->>$ct</option>
<!--#end for#--> <!--#end for#-->
</select> </select>
<!--#end if#--> <!--#end if#-->
<select title="Processing" class="proc_option"> <select title="Processing" class="change_opts">
<option value="0" <!--#if $slot.unpackopts == "0" then "selected " else ""#-->>Skip</option> <option value="0" <!--#if $slot.unpackopts == "0" then "selected " else ""#-->>Skip</option>
<option value="1" <!--#if $slot.unpackopts == "1" then "selected " else ""#-->>+Repair</option> <option value="1" <!--#if $slot.unpackopts == "1" then "selected " else ""#-->>+Repair</option>
<option value="2" <!--#if $slot.unpackopts == "2" then "selected " else ""#-->>+R+Unpack</option> <option value="2" <!--#if $slot.unpackopts == "2" then "selected " else ""#-->>+R+Unpack</option>
<option value="3" <!--#if $slot.unpackopts == "3" then "selected " else ""#-->>+R+U+Delete</option> <option value="3" <!--#if $slot.unpackopts == "3" then "selected " else ""#-->>+R+U+Delete</option>
</select> </select>
<!--#if $script_list#--> <!--#if $script_list#-->
<select title="Script" class="proc_script"> <select title="Script" class="change_script">
<!--#for $sc in $script_list#--> <!--#for $sc in $script_list#-->
<option value="$sc" <!--#if $slot.script == $sc then "selected" else ""#-->>$sc</option> <option value="$sc" <!--#if $slot.script == $sc then "selected" else ""#-->>$sc</option>
<!--#end for#--> <!--#end for#-->

122
main/interfaces/Plush/templates/static/javascripts/main.js

@ -144,6 +144,7 @@ jQuery(function($) {
$.plush = { $.plush = {
/******************************************** /********************************************
********************************************* *********************************************
@ -151,20 +152,19 @@ jQuery(function($) {
********************************************* *********************************************
********************************************/ ********************************************/
refreshRate : 30, // in seconds, how long to wait until updating all the content refreshRate : 30, // default refresh rate, overridden by cookie
skipRefresh : false, // used when the cursor is hovering the queue skipRefresh : false, // used when the cursor is hovering the queue
queueViewPreference : 15, // nzb limit queueViewPreference : 15, // queue nzb limiter
historyViewPreference : 15, // nzb limit historyViewPreference : 15, // history nzb limiter
focusedOnSpeedChanger : false, // focusedOnSpeedChanger : false, // don't update speed limit when editing + queue refreshes
/******************************************** /********************************************
********************************************* *********************************************
$.plush.refreshQueue() $.plush.refreshQueue() -- fetch HTML data from queue.tmpl
replaces queue contents with new html from queue.tmpl also make updates throughout interface
also makes updates throughout interface
********************************************* *********************************************
********************************************/ ********************************************/
@ -201,19 +201,20 @@ jQuery(function($) {
$('#manual_refresh').addClass('refresh_skipped'); $('#manual_refresh').addClass('refresh_skipped');
} }
}); });
},
}, // end refreshQueue()
/******************************************** /********************************************
********************************************* *********************************************
$.plush.refreshHistory() $.plush.refreshHistory() -- fetch HTML data from history.tmpl
********************************************* *********************************************
********************************************/ ********************************************/
refreshHistory : function() { refreshHistory : function() {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "history/", url: "history/",
@ -222,20 +223,21 @@ jQuery(function($) {
$('#history').html(result); $('#history').html(result);
} }
}); });
},
}, // end refreshHistory()
/******************************************** /********************************************
********************************************* *********************************************
$.plush.refresh() -- drag & drop sorting $.plush.refresh() -- triggers refreshQueue & refreshHistory then calls itself
********************************************* *********************************************
********************************************/ ********************************************/
refresh : function() { // calls itself after `refreshRate` seconds refresh : function() { // calls itself after `refreshRate` seconds
// clear out timeout in case multiple refreshes are triggered // clear timeout in case multiple refreshes are triggered
clearTimeout($.plush.timeout); clearTimeout($.plush.timeout);
// ajax calls // ajax calls
@ -245,7 +247,8 @@ jQuery(function($) {
// loop // loop
if ($.plush.refreshRate > 0) if ($.plush.refreshRate > 0)
$.plush.timeout = setTimeout("$.plush.refresh()", $.plush.refreshRate*1000); $.plush.timeout = setTimeout("$.plush.refresh()", $.plush.refreshRate*1000);
},
}, // end refresh()
/******************************************** /********************************************
@ -258,6 +261,7 @@ jQuery(function($) {
initEvents : function() { initEvents : function() {
/******************************************** /********************************************
********************************************* *********************************************
@ -266,7 +270,6 @@ jQuery(function($) {
********************************************* *********************************************
********************************************/ ********************************************/
// Fetch NZB by URL/Newzbin Report ID // Fetch NZB by URL/Newzbin Report ID
$('#addID').bind('click', function() { $('#addID').bind('click', function() {
if ($('#addID_input').val()!='enter URL / Newzbin ID') { if ($('#addID_input').val()!='enter URL / Newzbin ID') {
@ -290,7 +293,6 @@ jQuery(function($) {
$(this).val('enter URL / Newzbin ID'); $(this).val('enter URL / Newzbin ID');
}); });
// NZB File Upload // NZB File Upload
$('#addNZBbyFile').upload({ $('#addNZBbyFile').upload({
name: 'name', name: 'name',
@ -310,13 +312,11 @@ jQuery(function($) {
********************************************* *********************************************
********************************************/ ********************************************/
// activate main menu
// activate main menu, already uses hoverIntent $("ul.sf-menu").superfish({ // also uses hoverIntent
$("ul.sf-menu").superfish({
pathClass: 'current' pathClass: 'current'
}); });
// Refresh Rate main menu input // Refresh Rate main menu input
if ($.cookie('Plush2Refresh')) // restore from cookie if ($.cookie('Plush2Refresh')) // restore from cookie
$.plush.refreshRate = $.cookie('Plush2Refresh'); $.plush.refreshRate = $.cookie('Plush2Refresh');
@ -330,7 +330,6 @@ jQuery(function($) {
clearTimeout($.plush.timeout); clearTimeout($.plush.timeout);
}); });
// Max Speed main menu input // Max Speed main menu input
$("#maxSpeed-option").focus(function(){ $.plush.focusedOnSpeedChanger = true; }) $("#maxSpeed-option").focus(function(){ $.plush.focusedOnSpeedChanger = true; })
.blur(function(){ $.plush.focusedOnSpeedChanger = false; }); .blur(function(){ $.plush.focusedOnSpeedChanger = false; });
@ -342,7 +341,6 @@ jQuery(function($) {
}); });
}); });
// Upon Queue Completion main menu select // Upon Queue Completion main menu select
$("#onQueueFinish-option").change( function() { $("#onQueueFinish-option").change( function() {
$.ajax({ $.ajax({
@ -366,46 +364,24 @@ jQuery(function($) {
} }
}); });
// Sort Queue main menu options // 3-in-1 queue sort ajax (via main menu)
$('#sort_by_avg_age').click(function(event) { $('#sort_by_avg_age, #sort_by_name, #sort_by_size').click(function() {
$.ajax({
type: "POST",
url: "tapi",
data: "queue/sort_by_avg_age",
success: function(){
$.plush.refreshQueue()
}
});
});
$('#sort_by_name').click(function(event) {
$.ajax({
type: "POST",
url: "tapi",
data: "queue/sort_by_name",
success: function(){
$.plush.refreshQueue()
}
});
});
$('#sort_by_size').click(function(event) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "tapi", url: "tapi",
data: "queue/sort_by_size", data: "queue/"+$(this).attr('id'),
success: function(){ success: function(){
$.plush.refreshQueue() $.plush.refreshQueue()
} }
}); });
}); });
// set up "shutdown sabnzbd" from main menu // set up "shutdown sabnzbd" from main menu
$('#shutdown_sabnzbd').click( function(){ $('#shutdown_sabnzbd').click( function(){
if(confirm('Sure you want to shut down the SABnzbd application?')) if(confirm('Sure you want to shut down the SABnzbd application?'))
window.location='shutdown'; window.location='shutdown';
}); });
// manual refresh // manual refresh
$('#manual_refresh_wrapper').click(function(event) { $('#manual_refresh_wrapper').click(function(event) {
$.plush.refreshQueue(); $.plush.refreshQueue();
@ -421,7 +397,6 @@ jQuery(function($) {
********************************************* *********************************************
********************************************/ ********************************************/
// this code will remain instantiated even when the contents of the queue change // this code will remain instantiated even when the contents of the queue change
$('#queueTable').livequery(function() { $('#queueTable').livequery(function() {
@ -537,9 +512,7 @@ jQuery(function($) {
// reposition the nzb if necessary (new position is returned by the API) // reposition the nzb if necessary (new position is returned by the API)
if (oldPos == newPos) if (oldPos == newPos)
return; return;
if (newPos == "0") else if (oldPos < newPos)
$('#'+nzbid).insertBefore($('#queueTable tr:first-child'));
else if (oldPos < newPos)
$('#'+nzbid).insertAfter($('#queueTable tr:eq('+ newPos +')')); $('#'+nzbid).insertAfter($('#queueTable tr:eq('+ newPos +')'));
else else
$('#'+nzbid).insertBefore($('#queueTable tr:eq('+ newPos +')')); $('#'+nzbid).insertBefore($('#queueTable tr:eq('+ newPos +')'));
@ -547,30 +520,12 @@ jQuery(function($) {
}); });
}); });
// nzb change category ajax // 3-in-1 change nzb [category + processing + script] ajax
$('#queueTable .proc_category').change(function(){ $('.change_cat, .change_opts, .change_script').change(function(){
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "tapi", url: "tapi",
data: "mode=change_cat&value="+$(this).parent().parent().attr('id')+'&value2='+$(this).val() data: "mode="+$(this).attr('class')+"&value="+$(this).parent().parent().attr('id')+'&value2='+$(this).val()
});
});
// nzb change processing option ajax
$('#queueTable .proc_option').change(function(){
$.ajax({
type: "POST",
url: "tapi",
data: "mode=change_opts&value="+$(this).parent().parent().attr('id')+'&value2='+$(this).val()
});
});
// nzb change script ajax
$('#queueTable .proc_script').change(function(){
$.ajax({
type: "POST",
url: "tapi",
data: "mode=change_script&value="+$(this).parent().parent().attr('id')+'&value2='+$(this).val()
}); });
}); });
@ -622,7 +577,6 @@ jQuery(function($) {
}); });
/******************************************** /********************************************
********************************************* *********************************************
@ -631,7 +585,6 @@ jQuery(function($) {
********************************************* *********************************************
********************************************/ ********************************************/
// history purge // history purge
$('.h_menu_purge').click(function(event) { $('.h_menu_purge').click(function(event) {
if (confirm("Are you sure you want to purge the history?")) { if (confirm("Are you sure you want to purge the history?")) {
@ -659,7 +612,6 @@ jQuery(function($) {
} }
}); });
// this code will remain instantiated even when the contents of the history change // this code will remain instantiated even when the contents of the history change
$('#history .left_stats').livequery(function() { $('#history .left_stats').livequery(function() {
@ -672,7 +624,6 @@ jQuery(function($) {
}); // end livequery }); // end livequery
// this code will remain instantiated even when the contents of the history change // this code will remain instantiated even when the contents of the history change
$('#historyTable').livequery(function() { $('#historyTable').livequery(function() {
@ -694,14 +645,12 @@ jQuery(function($) {
********************************************* *********************************************
********************************************/ ********************************************/
// restore queue/history view preferences (or set to defaults) // restore queue/history view preferences (or set to defaults)
if ($.cookie('queue_view_preference')) if ($.cookie('queue_view_preference'))
$.plush.queueViewPreference = $.cookie('queue_view_preference'); $.plush.queueViewPreference = $.cookie('queue_view_preference');
if ($.cookie('history_view_preference')) if ($.cookie('history_view_preference'))
$.plush.historyViewPreference = $.cookie('history_view_preference'); $.plush.historyViewPreference = $.cookie('history_view_preference');
// additional tooltips // additional tooltips
$('.tip').tooltip({ $('.tip').tooltip({
extraClass: "tooltip", extraClass: "tooltip",
@ -709,26 +658,15 @@ jQuery(function($) {
fixPNG: true fixPNG: true
}); });
// fix IE6 .png image transparencies // fix IE6 .png image transparencies
$('img[@src$=.png], div.history_logo, div.queue_logo, li.q_menu_addnzb, li.q_menu_pause, li.h_menu_verbose, li.h_menu_purge, div#time-left, div#speed').ifixpng(); $('img[@src$=.png], div.history_logo, div.queue_logo, li.q_menu_addnzb, li.q_menu_pause, li.h_menu_verbose, li.h_menu_purge, div#time-left, div#speed').ifixpng();
} // end of $.plush.initEvents() } // end initEvents()
}; // end plush object }; // end plush object
}); });
/*
// disables toggler text selection when clicking
function disableSelection(element) {
element.onselectstart = function() {
return false;
};
element.unselectable = "on";
element.style.MozUserSelect = "none";
element.style.cursor = "default";
};
*/
// once the DOM is ready, run this // once the DOM is ready, run this
jQuery(document).ready(function($){ jQuery(document).ready(function($){

Loading…
Cancel
Save