Change Config/Media Providers/Custom Newznab "Extra categories..." for disabled nzb providers.

This commit is contained in:
JackDandy 2016-12-20 16:30:59 +00:00
parent 2b27e3bb74
commit f356099293
4 changed files with 517 additions and 549 deletions

View file

@ -677,7 +677,7 @@ name = '' if not client else get_client_instance(sickbeard.TORRENT_METHOD)().nam
<span style="font-weight:normal">with.. (u)hd, sd, sport, anime</span>
</span>
<span class="component-desc">
<div id="nn-cats">
<div id="nn-cats" class="hide">
<div class="pull-left">
<select class="pull-left" id="newznab_cap" multiple="multiple" style="min-width:10em;min-height:72px"></select>
<input class="btn" type="button" class="newznab_cat_update" id="newznab_cat_update" value=">>" style="position:relative;bottom:-15px">
@ -691,8 +691,11 @@ name = '' if not client else get_client_instance(sickbeard.TORRENT_METHOD)().nam
<div id="nn-nocats" class="hide">
<span>No extra categories found</span>
</div>
<div id="nn-enable-for-cats" class="hide">
<span class="grey-text">Enable provider for categories</span>
</div>
<div id="nn-loadcats" class="hide">
<span>Loading categories...</span>
<span class="grey-text">Loading categories...</span>
</div>
</span>
</label>

View file

@ -74,7 +74,7 @@
<!--
var sbRoot = '$sbRoot', anonURL = '$sg_str('ANON_REDIRECT')', themeSpinner = '#echo ('', '-dark')['dark' == $sg_str('THEME_NAME', 'dark')]#',
top_image_html = '<img src="$sbRoot/images/top.gif" width="31" height="11" alt="Jump to top" />', topmenu = '$topmenu';
\$.SickGear = {Root: '${sbRoot}', PID: '${sbPID}'};
\$.SickGear = {Root: '${sbRoot}', PID: '${sbPID}', anonURL: '$sg_str('ANON_REDIRECT')'};
//-->
</script>
<script type="text/javascript" src="$sbRoot/js/lib/jquery.scrolltopcontrol-1.1.js"></script>

View file

@ -1,49 +1,47 @@
/** @namespace $.SickGear.Root */
/** @namespace $.SickGear.anonURL */
$(document).ready(function(){
$.sgd = !1;
$.fn.showHideProviders = function() {
$.fn.showHideProviders = function(){
$('.providerDiv').each(function(){
var providerName = $(this).attr('id');
var selectedProvider = $('#editAProvider :selected').val();
var selectedProvider = $('#editAProvider').find(':selected').val();
if (selectedProvider + 'Div' == providerName) {
if (selectedProvider + 'Div' == providerName){
$(this).show();
} else {
$(this).hide();
}
});
}
};
/**
* Gets categories for the provided newznab provider.
* @param {String} isDefault
* no return data. Function updateNewznabCaps() is run at callback
* @param {String} isNative
* @param {Array} selectedProvider
* @return no return data. Function updateNewznabCaps() is run at callback
* @return
*/
$.fn.getCategories = function (isDefault, selectedProvider) {
$.fn.getCategories = function(isNative, selectedProvider){
var name = selectedProvider[0];
var url = selectedProvider[1];
var key = selectedProvider[2];
if (!name)
return;
if (!url)
return;
if (!key)
if (!name || !url || !key)
return;
var params = {url: url, name: name, key: key};
var returnData;
$.getJSON(sbRoot + '/config/providers/getNewznabCategories', params,
$.getJSON($.SickGear.Root + '/config/providers/getNewznabCategories', params,
function(data){
updateNewznabCaps( data, selectedProvider );
updateNewznabCaps(data, selectedProvider);
});
}
};
$.fn.addProvider = function (id, name, url, key, cat, isDefault, showProvider) {
$.fn.addProvider = function(id, name, url, key, cat, isNative, showProvider){
url = $.trim(url);
if (!url)
@ -52,50 +50,51 @@ $(document).ready(function(){
if (!/^https?:\/\//i.test(url))
url = 'http://' + url;
if (url.match('/$') == null)
url = url + '/';
url += /[^/]$/.test(url) && '/' || '';
var newData = [isDefault, [name, url, key, cat]];
newznabProviders[id] = newData;
newznabProviders[id] = [isNative, [name, url, key, cat]];
if (!isDefault){
if (!isNative){
$('#editANewznabProvider').addOption(id, name);
$(this).populateNewznabSection();
}
if ($('#provider_order_list > #' + id).length == 0 && showProvider != false) {
var toAdd = '<li class="ui-state-default" id="' + id + '"> <input type="checkbox" id="enable_' + id + '" class="provider_enabler" CHECKED> <a href="' + anonURL + url + '" class="imgLink" target="_new"><img src="' + sbRoot
+ '/images/providers/newznab.png" alt="' + name + '" width="16" height="16"></a> ' + name + '</li>'
if (0 == $('#provider_order_list > #' + id).length && !1 != showProvider){
var toAdd = '<li class="ui-state-default" id="' + id + '"> '
+ '<input type="checkbox" id="enable_' + id + '" class="provider_enabler" CHECKED> '
+ '<a href="' + $.SickGear.anonURL + url + '" class="imgLink" target="_new">'
+ '<img src="' + $.SickGear.Root + '/images/providers/newznab.png" alt="' + name + '" width="16" height="16"></a> '
+ name + '</li>', prov$ = $('#provider_order_list');
$('#provider_order_list').append(toAdd);
$('#provider_order_list').sortable('refresh');
prov$.append(toAdd);
prov$.sortable('refresh');
}
$(this).makeNewznabProviderString();
};
}
$.fn.addTorrentRssProvider = function(id, name, url, cookies){
$.fn.addTorrentRssProvider = function (id, name, url, cookies) {
var newData = [name, url, cookies];
torrentRssProviders[id] = newData;
torrentRssProviders[id] = [name, url, cookies];
$('#editATorrentRssProvider').addOption(id, name);
$(this).populateTorrentRssSection();
if ($('#provider_order_list > #' + id).length == 0) {
var toAdd = '<li class="ui-state-default" id="' + id + '"> <input type="checkbox" id="enable_' + id + '" class="provider_enabler" CHECKED> <a href="' + anonURL + url + '" class="imgLink" target="_new"><img src="' + sbRoot
+ '/images/providers/torrentrss.png" alt="' + name + '" width="16" height="16"></a> ' + name + '</li>'
if (0 == $('#provider_order_list > #' + id).length){
var toAdd = '<li class="ui-state-default" id="' + id + '"> '
+ '<input type="checkbox" id="enable_' + id + '" class="provider_enabler" CHECKED> '
+ '<a href="' + $.SickGear.anonURL + url + '" class="imgLink" target="_new">'
+ '<img src="' + $.SickGear.Root + '/images/providers/torrentrss.png" alt="' + name + '" width="16" height="16"></a> '
+ name + '</li>', prov$ = $('#provider_order_list');
$('#provider_order_list').append(toAdd);
$('#provider_order_list').sortable('refresh');
prov$.append(toAdd);
prov$.sortable('refresh');
}
$(this).makeTorrentRssProviderString();
};
}
$.fn.updateProvider = function (id, url, key, cat) {
$.fn.updateProvider = function(id, url, key, cat){
newznabProviders[id][1][1] = url;
newznabProviders[id][1][2] = key;
@ -104,117 +103,99 @@ $(document).ready(function(){
$(this).populateNewznabSection();
$(this).makeNewznabProviderString();
};
}
$.fn.deleteProvider = function (id) {
$.fn.deleteProvider = function(id){
$('#editANewznabProvider').removeOption(id);
delete newznabProviders[id];
$(this).populateNewznabSection();
$('li').remove('#' + id);
$(this).makeNewznabProviderString();
};
}
$.fn.updateTorrentRssProvider = function (id, url, cookies) {
$.fn.updateTorrentRssProvider = function(id, url, cookies){
torrentRssProviders[id][1] = url;
torrentRssProviders[id][2] = cookies;
$(this).populateTorrentRssSection();
$(this).makeTorrentRssProviderString();
}
};
$.fn.deleteTorrentRssProvider = function (id) {
$.fn.deleteTorrentRssProvider = function(id){
$('#editATorrentRssProvider').removeOption(id);
delete torrentRssProviders[id];
$(this).populateTorrentRssSection();
$('li').remove('#' + id);
$(this).makeTorrentRssProviderString();
}
};
$.fn.populateNewznabSection = function() {
$.fn.populateNewznabSection = function(){
var selectedProvider = $('#editANewznabProvider :selected').val();
var data, isNative, rrcat, selectedProvider = $('#editANewznabProvider').find(':selected').val(),
nnName$ = $('#newznab_name'), nnCat$ = $('#newznab_cat'), nn$ = $('#newznab_cat, #newznab_cap');
if (selectedProvider == 'addNewznab') {
var data = ['','',''];
var isDefault = 0;
if ('addNewznab' == selectedProvider){
data = ['','',''];
isNative = 0;
$('#newznab_add_div').show();
$('#newznab_update_div').hide();
$('#newznab_cat').attr('disabled','disabled');
$('#newznab_cap').attr('disabled','disabled');
$('#newznab_cat option').each(function() {
nn$.find('option').each(function(){
$(this).remove();
return;
});
$('#newznab_cap option').each(function() {
$(this).remove();
return;
});
nn$.attr('disabled', 'disabled');
} else {
var data = newznabProviders[selectedProvider][1];
var isDefault = newznabProviders[selectedProvider][0];
data = newznabProviders[selectedProvider][1];
isNative = newznabProviders[selectedProvider][0];
$('#newznab_add_div').hide();
$('#newznab_update_div').show();
$('#newznab_cat').removeAttr('disabled');
$('#newznab_cap').removeAttr('disabled');
nn$.removeAttr('disabled');
}
$('#newznab_name').val(data[0]);
nnName$.val(data[0]);
$('#newznab_url').val(data[1]);
$('#newznab_key').val(data[2]);
//Check if not already array
if (typeof data[3] === 'string') {
rrcat = data[3].split(',')
}
else {
rrcat = data[3];
}
rrcat = ('string' === typeof data[3]) ? data[3].split(',') : data[3];
// Update the category select box (on the right)
var newCatOptions = [];
if (rrcat) {
rrcat.forEach(function (cat) {
if (rrcat){
rrcat.forEach(function(cat){
newCatOptions.push({text : cat, value : cat});
});
$('#newznab_cat').replaceOptions(newCatOptions);
};
nnCat$.replaceOptions(newCatOptions);
}
if ('addNewznab' == selectedProvider) {
$('#newznab_url, #newznab_name').removeAttr('disabled');
if (selectedProvider == 'addNewznab') {
$('#newznab_name').removeAttr('disabled');
$('#newznab_url').removeAttr('disabled');
} else {
$('#newznab_name').attr('disabled', 'disabled');
nnName$.attr('disabled', 'disabled');
if (isDefault) {
$('#newznab_url').attr('disabled', 'disabled');
$('#newznab_delete').attr('disabled', 'disabled');
if (isNative){
$('#newznab_url, #newznab_delete').attr('disabled', 'disabled');
} else {
$('#newznab_url').removeAttr('disabled');
$('#newznab_delete').removeAttr('disabled');
$('#newznab_url, #newznab_delete').removeAttr('disabled');
//Get Categories Capabilities
if (data[0] && data[1] && data[2] && !ifExists($.fn.newznabProvidersCapabilities, data[0])) {
$(this).getCategories(isDefault, data);
}
else {
updateNewznabCaps( null, data );
}
if (data[0] && data[1] && data[2] && !ifExists($.fn.newznabProvidersCapabilities, data[0])){
$(this).getCategories(isNative, data);
} else {
updateNewznabCaps(null, data);
}
}
}
};
ifExists = function(loopThroughArray, searchFor) {
var found = false;
var ifExists = function(loopThroughArray, searchFor){
var found = !1;
loopThroughArray.forEach(function(rootObject) {
if (rootObject.name == searchFor) {
found = true;
loopThroughArray.forEach(function(rootObject){
if (rootObject.name == searchFor){
found = !0;
}
});
return found;
@ -227,27 +208,33 @@ $(document).ready(function(){
* @param {Array} selectedProvider
* @return no return data. The multiselect input $("#newznab_cap") is updated, as a result.
*/
updateNewznabCaps = function( newzNabCaps, selectedProvider ) {
/** @namespace newzNabCaps.tv_categories */
var updateNewznabCaps = function(newzNabCaps, selectedProvider){
if (newzNabCaps && !ifExists($.fn.newznabProvidersCapabilities, selectedProvider[0])) {
if (newzNabCaps && !ifExists($.fn.newznabProvidersCapabilities, selectedProvider[0])){
$.fn.newznabProvidersCapabilities.push({
'name' : selectedProvider[0],
'enabled' : newzNabCaps.state,
'categories' : newzNabCaps.tv_categories
.sort(function(a, b){return a.name > b.name})})
}
$.sgd && console.log(selectedProvider);
//Loop through the array and if currently selected newznab provider name matches one in the array, use it to
//update the capabilities select box (on the left).
if (selectedProvider[0]) {
var newCapOptions = [], catName = '', hasCats = false;
if ($.fn.newznabProvidersCapabilities.length) {
$.fn.newznabProvidersCapabilities.forEach(function (newzNabCap) {
$.sgd && console.log('array found:' + (newzNabCap.categories instanceof Array ? 'yes': 'no'));
if (selectedProvider[0]){
var elShow, newCapOptions = [], catName = '', hasCats = !1, enabled = !1;
if ($.fn.newznabProvidersCapabilities.length){
$.fn.newznabProvidersCapabilities.forEach(function(newzNabCap){
if (newzNabCap.name && newzNabCap.name == selectedProvider[0]) {
$.sgd && console.log('newzNabCap...');
$.sgd && console.log(newzNabCap);
enabled = newzNabCap.enabled;
if (newzNabCap.name && newzNabCap.name == selectedProvider[0] && newzNabCap.categories instanceof Array) {
newzNabCap.categories.forEach(function (category_set) {
if (category_set.id && category_set.name) {
if (newzNabCap.categories instanceof Array) {
newzNabCap.categories.forEach(function(category_set){
if (category_set.id && category_set.name){
catName = category_set.name.replace(/Docu([^\w]|$)(.*?)/i, 'Documentary$1');
newCapOptions.push({
value: category_set.id,
@ -258,95 +245,92 @@ $(document).ready(function(){
$('#newznab_cap').replaceOptions(newCapOptions);
hasCats = !!newCapOptions.length
}
});
$('#nn-loadcats').removeClass('show').addClass('hide');
if (hasCats) {
$.sgd && console.log('hasCats');
$('#nn-nocats').removeClass('show').addClass('hide');
$('#nn-cats').removeClass('hide').addClass('show');
} else {
$.sgd && console.log('noCats');
$('#nn-cats').removeClass('show').addClass('hide');
$('#nn-nocats').removeClass('hide').addClass('show');
return !1;
}
});
$('#nn-cats, #nn-nocats, #nn-enable-for-cats, #nn-loadcats').removeClass('show').addClass('hide');
if (!enabled) {
elShow = '#nn-enable-for-cats'
} else if (hasCats){
elShow = '#nn-cats';
} else {
$.sgd && console.log('errCats');
// error - no caps
$('#nn-cats').removeClass('show').addClass('hide');
$('#nn-nocats').removeClass('show').addClass('hide');
elShow = '#nn-nocats';
}
$.sgd && console.log('for ' + selectedProvider[0] + ' unhide("' + elShow + '")');
$(elShow).removeClass('hide').addClass('show');
} else {
$.sgd && console.log('no caps - yet');
$('#nn-cats, #nn-nocats').removeClass('show').addClass('hide');
$('#nn-loadcats').removeClass('hide').addClass('show');
}
}
}
};
$.fn.makeNewznabProviderString = function() {
$.fn.makeNewznabProviderString = function(){
var provStrings = new Array();
var provStrings = [];
for (var id in newznabProviders) {
for (var id in newznabProviders){
provStrings.push(newznabProviders[id][1].join('|'));
}
$('#newznab_string').val(provStrings.join('!!!'))
};
}
$.fn.populateTorrentRssSection = function(){
$.fn.populateTorrentRssSection = function() {
var data, selectedProvider = $('#editATorrentRssProvider').find(':selected').val(),
torRSSadd$ = $('#torrentrss_add_div'), torRSSupd$ = $('#torrentrss_update_div'),
torRSSname$ = $('#torrentrss_name');
var selectedProvider = $('#editATorrentRssProvider :selected').val();
if (selectedProvider == 'addTorrentRss') {
var data = ['','',''];
$('#torrentrss_add_div').show();
$('#torrentrss_update_div').hide();
if ('addTorrentRss' == selectedProvider) {
data = ['', '', ''];
torRSSadd$.show();
torRSSupd$.hide();
} else {
var data = torrentRssProviders[selectedProvider];
$('#torrentrss_add_div').hide();
$('#torrentrss_update_div').show();
data = torrentRssProviders[selectedProvider];
torRSSadd$.hide();
torRSSupd$.show();
}
$('#torrentrss_name').val(data[0]);
torRSSname$.val(data[0]);
$('#torrentrss_url').val(data[1]);
$('#torrentrss_cookies').val(data[2]);
if (selectedProvider == 'addTorrentRss') {
$('#torrentrss_name').removeAttr('disabled');
$('#torrentrss_url').removeAttr('disabled');
$('#torrentrss_cookies').removeAttr('disabled');
if ('addTorrentRss' == selectedProvider) {
$('#torrentrss_name, #torrentrss_url, #torrentrss_cookies').removeAttr('disabled');
} else {
$('#torrentrss_name').attr('disabled', 'disabled');
$('#torrentrss_url').removeAttr('disabled');
$('#torrentrss_cookies').removeAttr('disabled');
$('#torrentrss_delete').removeAttr('disabled');
torRSSname$.attr('disabled', 'disabled');
$('#torrentrss_url, #torrentrss_cookies, #torrentrss_delete').removeAttr('disabled');
}
};
}
$.fn.makeTorrentRssProviderString = function(){
$.fn.makeTorrentRssProviderString = function() {
var provStrings = new Array();
for (var id in torrentRssProviders) {
var provStrings = [];
for (var id in torrentRssProviders){
provStrings.push(torrentRssProviders[id].join('|'));
}
$('#torrentrss_string').val(provStrings.join('!!!'))
}
};
$.fn.refreshProviderList = function() {
$.fn.refreshProviderList = function(){
var idArr = $('#provider_order_list').sortable('toArray');
var finalArr = new Array();
$.each(idArr, function(key, val) {
var finalArr = [];
$.each(idArr, function(key, val){
var checked = + $('#enable_' + val).prop('checked') ? '1' : '0';
finalArr.push(val + ':' + checked);
});
$('#provider_order').val(finalArr.join(' '));
}
};
var newznabProviders = new Array();
var torrentRssProviders = new Array();
var newznabProviders = [];
var torrentRssProviders = [];
$(this).on('change', '.newznab_key', function(){
@ -361,17 +345,16 @@ $(document).ready(function(){
});
$('#newznab_key,#newznab_url').change(function(){
$('#newznab_key, #newznab_url').change(function(){
var selectedProvider = $('#editANewznabProvider :selected').val();
var selectedProvider = $('#editANewznabProvider').find(':selected').val();
if (selectedProvider == 'addNewznab')
if ('addNewznab' == selectedProvider)
return;
var url = $('#newznab_url').val();
var key = $('#newznab_key').val();
var cat = $('#newznab_cat option').map(function(i, opt) {
var url = $('#newznab_url').val(),
key = $('#newznab_key').val(),
cat = $('#newznab_cat').find('option').map(function(i, opt){
return $(opt).text();
}).toArray().join(',');
@ -379,15 +362,15 @@ $(document).ready(function(){
});
$('#torrentrss_url,#torrentrss_cookies').change(function(){
$('#torrentrss_url, #torrentrss_cookies').change(function(){
var selectedProvider = $('#editATorrentRssProvider :selected').val();
var selectedProvider = $('#editATorrentRssProvider').find(':selected').val();
if (selectedProvider == 'addTorrentRss')
if ('addTorrentRss' == selectedProvider)
return;
var url = $('#torrentrss_url').val();
var cookies = $('#torrentrss_cookies').val();
var url = $('#torrentrss_url').val(),
cookies = $('#torrentrss_cookies').val();
$(this).updateTorrentRssProvider(selectedProvider, url, cookies);
});
@ -411,111 +394,89 @@ $(document).ready(function(){
$(this).on('click', '#newznab_cat_update', function(){
var nnCat$ = $('#newznab_cat');
//Maybe check if there is anything selected?
$('#newznab_cat option').each(function() {
nnCat$.find('option').each(function(){
$(this).remove();
return;
});
var newOptions = [];
// When the update botton is clicked, loop through the capabilities list
// and copy the selected category id's to the category list on the right.
$('#newznab_cap option').each(function(){
if($(this).attr('selected') == 'selected')
{
$('#newznab_cap').find(':selected').each(function(){
var selected_cat = $(this).val();
newOptions.push({text: selected_cat, value: selected_cat})
};
});
$('#newznab_cat').replaceOptions(newOptions);
nnCat$.replaceOptions(newOptions);
var selectedProvider = $('#editANewznabProvider :selected').val();
if (selectedProvider == 'addNewznab')
var selectedProvider = $('#editANewznabProvider').find(':selected').val();
if ('addNewznab' == selectedProvider)
return;
var url = $('#newznab_url').val();
var key = $('#newznab_key').val();
var cat = $('#newznab_cat option').map(function(i, opt) {
var cat = nnCat$.find('option').map(function(i, opt){
return $(opt).text();
}).toArray().join(',');
$('#newznab_cat option:not([value])').remove();
nnCat$.find('option:not([value])').remove();
$(this).updateProvider(selectedProvider, url, key, cat);
});
$('#newznab_add').click(function(){
var selectedProvider = $('#editANewznabProvider :selected').val();
var name = $.trim($('#newznab_name').val());
var url = $.trim($('#newznab_url').val());
var key = $.trim($('#newznab_key').val());
//var cat = $.trim($('#newznab_cat').val());
var cat = $.trim($('#newznab_cat option').map(function(i, opt) {
var cat = $.trim($('#newznab_cat').find('option').map(function(i, opt){
return $(opt).text();}).toArray().join(','));
if (!name)
if (!name || !url || !key)
return;
if (!url)
return;
if (!key)
return;
var params = {name: name};
// send to the form with ajax, get a return value
$.getJSON(sbRoot + '/config/providers/canAddNewznabProvider', params,
$.getJSON($.SickGear.Root + '/config/providers/canAddNewznabProvider', {name: name},
function(data){
if (data.error != undefined) {
if (data.error != undefined){
alert(data.error);
return;
}
$(this).addProvider(data.success, name, url, key, cat, 0);
});
});
$('.newznab_delete').click(function(){
var selectedProvider = $('#editANewznabProvider :selected').val();
var selectedProvider = $('#editANewznabProvider').find(':selected').val();
$(this).deleteProvider(selectedProvider);
});
$('#torrentrss_add').click(function(){
var selectedProvider = $('#editATorrentRssProvider :selected').val();
var name = $('#torrentrss_name').val();
var url = $('#torrentrss_url').val();
var cookies = $('#torrentrss_cookies').val();
var params = { name: name, url: url, cookies: cookies}
var params = { name: name, url: url, cookies: cookies};
// send to the form with ajax, get a return value
$.getJSON(sbRoot + '/config/providers/canAddTorrentRssProvider', params,
$.getJSON($.SickGear.Root + '/config/providers/canAddTorrentRssProvider', params,
function(data){
if (data.error != undefined) {
if (data.error != undefined){
alert(data.error);
return;
}
$(this).addTorrentRssProvider(data.success, name, url, cookies);
});
});
$('.torrentrss_delete').on('click', function(){
var selectedProvider = $('#editATorrentRssProvider :selected').val();
var selectedProvider = $('#editATorrentRssProvider').find(':selected').val();
$(this).deleteTorrentRssProvider(selectedProvider);
});
@ -527,37 +488,37 @@ $(document).ready(function(){
$(this).on('change', '[class="providerDiv_tip"] select', function(){
$(this).find('option').each( function() {
if ($(this).is(':selected')) {
$(this).prop('defaultSelected', true)
$(this).find('option').each(function(){
if ($(this).is(':selected')){
$(this).prop('defaultSelected', !0)
} else {
$(this).prop('defaultSelected', false);
$(this).prop('defaultSelected', !1);
}
});
$('div .providerDiv ' + '[name=' + $(this).attr('name') + ']').empty().replaceWith($(this).clone())});
$(this).on('change', '.enabler', function(){
if ($(this).is(':checked')) {
$('.content_' + $(this).attr('id')).each( function() {
if ($(this).is(':checked')){
$('.content_' + $(this).attr('id')).each(function(){
$(this).show()
})
} else {
$('.content_' + $(this).attr('id')).each( function() {
$('.content_' + $(this).attr('id')).each(function(){
$(this).hide()
})
}
});
$('.enabler').each(function(){
if (!$(this).is(':checked')) {
if (!$(this).is(':checked')){
$('.content_' + $(this).attr('id')).hide();
} else {
$('.content_' + $(this).attr('id')).show();
}
});
$.fn.makeTorrentOptionString = function(provider_id) {
$.fn.makeTorrentOptionString = function(provider_id){
var seed_ratio = $('.providerDiv_tip #' + provider_id + '_seed_ratio').prop('value');
var seed_time = $('.providerDiv_tip #' + provider_id + '_seed_time').prop('value');
@ -565,25 +526,24 @@ $(document).ready(function(){
var option_string = $('.providerDiv_tip #' + provider_id + '_option_string');
option_string.val([seed_ratio, seed_time, process_met].join('|'))
}
};
$(this).on('change', '.seed_option', function(){
var provider_id = $(this).attr('id').split('_')[0];
$(this).makeTorrentOptionString(provider_id);
});
$.fn.replaceOptions = function(options) {
$.fn.replaceOptions = function(options){
var self, $option;
this.empty();
self = this;
$.each(options, function(index, option) {
$.each(options, function(index, option){
$option = $('<option></option>')
.attr('value', option.value)
.text(option.text);
@ -591,20 +551,22 @@ $(document).ready(function(){
});
};
//
// initialization stuff
//
$.fn.newznabProvidersCapabilities = [];
$(this).showHideProviders();
$('#provider_order_list').sortable({
var providers$ = $('#provider_order_list');
providers$.sortable({
placeholder: 'ui-state-highlight',
update: function (event, ui) {
update: function(event, ui){
$(this).refreshProviderList();
}
});
$('#provider_order_list').disableSelection();
providers$.disableSelection();
});

View file

@ -5121,7 +5121,9 @@ class ConfigProviders(Config):
return json.dumps({'success': False, 'error': error})
if name in [n.name for n in sickbeard.newznabProviderList if n.url == url]:
tv_categories = newznab.NewznabProvider.clean_newznab_categories([n for n in sickbeard.newznabProviderList if n.name == name][0].all_cats)
provider = [n for n in sickbeard.newznabProviderList if n.name == name][0]
tv_categories = newznab.NewznabProvider.clean_newznab_categories(provider.all_cats)
state = provider.is_enabled()
else:
providers = dict(zip([x.get_id() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList))
temp_provider = newznab.NewznabProvider(name, url, key)
@ -5129,8 +5131,9 @@ class ConfigProviders(Config):
temp_provider.key = providers[temp_provider.get_id()].key
tv_categories = newznab.NewznabProvider.clean_newznab_categories(temp_provider.all_cats)
state = False
return json.dumps({'success': True, 'tv_categories': tv_categories, 'error': ''})
return json.dumps({'success': True, 'tv_categories': tv_categories, 'state': state, 'error': ''})
def deleteNewznabProvider(self, nnid):