mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 15:32:31 +01:00
Fixed scripts on DownloadClient settings
This commit is contained in:
parent
f40305cb04
commit
171e0cbb31
@ -62,98 +62,100 @@
|
||||
<div id="result" class="hiddenResult">
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$('#downloadClientAccordion').accordion("activate", false);
|
||||
@section Scripts{
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$('#downloadClientAccordion').accordion("activate", false);
|
||||
|
||||
//Allow unobstrusive validation of the AJAX loaded form
|
||||
$.validator.unobtrusive.parse('#DownloadClientForm');
|
||||
//Allow unobstrusive validation of the AJAX loaded form
|
||||
$.validator.unobtrusive.parse('#DownloadClientForm');
|
||||
|
||||
//Validator Settings
|
||||
var settings = $.data($('#DownloadClientForm')[0], 'validator').settings;
|
||||
settings.ignore = [];
|
||||
settings.focusInvalid = false;
|
||||
settings.onfocusout = function (element) { $(element).valid(); };
|
||||
//Validator Settings
|
||||
var settings = $.data($('#DownloadClientForm')[0], 'validator').settings;
|
||||
settings.ignore = [];
|
||||
settings.focusInvalid = false;
|
||||
settings.onfocusout = function (element) { $(element).valid(); };
|
||||
|
||||
var oldHighlight = settings.highlight;
|
||||
var oldUnhighlight = settings.unhighlight;
|
||||
var oldHighlight = settings.highlight;
|
||||
var oldUnhighlight = settings.unhighlight;
|
||||
|
||||
settings.highlight = function (element, errorClass, validClass) {
|
||||
oldHighlight(element, errorClass, validClass);
|
||||
$(element).parents('div.ui-accordion-content').prev('h3.ui-accordion-header').addClass('validation-error');
|
||||
};
|
||||
settings.unhighlight = function (element, errorClass, validClass) {
|
||||
oldUnhighlight(element, errorClass, validClass);
|
||||
settings.highlight = function (element, errorClass, validClass) {
|
||||
oldHighlight(element, errorClass, validClass);
|
||||
$(element).parents('div.ui-accordion-content').prev('h3.ui-accordion-header').addClass('validation-error');
|
||||
};
|
||||
settings.unhighlight = function (element, errorClass, validClass) {
|
||||
oldUnhighlight(element, errorClass, validClass);
|
||||
|
||||
var container = $(element).parents('div.ui-accordion-content');
|
||||
if ($(container).children('.' + errorClass).length == 0)
|
||||
var container = $(element).parents('div.ui-accordion-content');
|
||||
if ($(container).children('.' + errorClass).length == 0)
|
||||
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
|
||||
};
|
||||
});
|
||||
|
||||
$(document).on('change', '#DownloadClient', function () {
|
||||
$("#DownloadClientForm").validate().form();
|
||||
|
||||
var container = $('div.ui-accordion-content');
|
||||
if ($(container).children('.input-validation-error').length == 0)
|
||||
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
|
||||
};
|
||||
});
|
||||
|
||||
$(document).on('change', '#DownloadClient', function () {
|
||||
$("#DownloadClientForm").validate().form();
|
||||
|
||||
var container = $('div.ui-accordion-content');
|
||||
if ($(container).children('.input-validation-error').length == 0)
|
||||
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
|
||||
});
|
||||
|
||||
var autoConfigureSabUrl = '@Url.Action("AutoConfigureSab", "Settings")';
|
||||
|
||||
function autoConfigureSab() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: autoConfigureSabUrl,
|
||||
error: function (req, status, error) {
|
||||
alert("Sorry! We could not autoconfigure SABnzbd for you");
|
||||
},
|
||||
success: autoConfigureSuccess
|
||||
});
|
||||
|
||||
function autoConfigureSuccess(data) {
|
||||
$('#SabHost').val(data.Host);
|
||||
$('#SabPort').val(data.Port);
|
||||
$('#SabApiKey').val(data.ApiKey);
|
||||
}
|
||||
}
|
||||
var sabCategoryUrl = '../Command/GetSabnzbdCategories';
|
||||
var autoConfigureSabUrl = '@Url.Action("AutoConfigureSab", "Settings")';
|
||||
|
||||
$('#SabTvCategory').focus(function () {
|
||||
var host = $('#SabHost').val();
|
||||
var port = $('#SabPort').val();
|
||||
var apiKey = $('#SabApiKey').val();
|
||||
var username = $('#SabUsername').val();
|
||||
var password = $('#SabPassword').val();
|
||||
function autoConfigureSab() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: autoConfigureSabUrl,
|
||||
error: function (req, status, error) {
|
||||
alert("Sorry! We could not autoconfigure SABnzbd for you");
|
||||
},
|
||||
success: autoConfigureSuccess
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: sabCategoryUrl,
|
||||
data: jQuery.param({ host: host, port: port, apiKey: apiKey, username: username, password: password }),
|
||||
error: function (req, status, error) {
|
||||
$.each($('#SabTvCategory option'), function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
$('#SabTvCategory').append($('<option />').val('tv').text('Please check your SABnzbd Settings'));
|
||||
},
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
//Get the current value
|
||||
var currentlySelected = $('#SabTvCategory').val();
|
||||
|
||||
//Remove all existing options
|
||||
$.each($('#SabTvCategory option'), function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
//Add the new ones
|
||||
$.each(data.categories, function () {
|
||||
$('#SabTvCategory').append($('<option />').val(this.toString()).text(this.toString()));
|
||||
});
|
||||
|
||||
//Attempt to reset to the preiously selected value (change to lower-case)
|
||||
$("#SabTvCategory").val(currentlySelected.toLowerCase());
|
||||
function autoConfigureSuccess(data) {
|
||||
$('#SabHost').val(data.Host);
|
||||
$('#SabPort').val(data.Port);
|
||||
$('#SabApiKey').val(data.ApiKey);
|
||||
}
|
||||
}
|
||||
var sabCategoryUrl = '../Command/GetSabnzbdCategories';
|
||||
|
||||
$('#SabTvCategory').focus(function () {
|
||||
var host = $('#SabHost').val();
|
||||
var port = $('#SabPort').val();
|
||||
var apiKey = $('#SabApiKey').val();
|
||||
var username = $('#SabUsername').val();
|
||||
var password = $('#SabPassword').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: sabCategoryUrl,
|
||||
data: jQuery.param({ host: host, port: port, apiKey: apiKey, username: username, password: password }),
|
||||
error: function (req, status, error) {
|
||||
$.each($('#SabTvCategory option'), function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
$('#SabTvCategory').append($('<option />').val('tv').text('Please check your SABnzbd Settings'));
|
||||
},
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
//Get the current value
|
||||
var currentlySelected = $('#SabTvCategory').val();
|
||||
|
||||
//Remove all existing options
|
||||
$.each($('#SabTvCategory option'), function () {
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
//Add the new ones
|
||||
$.each(data.categories, function () {
|
||||
$('#SabTvCategory').append($('<option />').val(this.toString()).text(this.toString()));
|
||||
});
|
||||
|
||||
//Attempt to reset to the preiously selected value (change to lower-case)
|
||||
$("#SabTvCategory").val(currentlySelected.toLowerCase());
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user