Radarr/NzbDrone.Web/Views/Settings/Test.cshtml

38 lines
1.5 KiB
Plaintext
Raw Normal View History

@Html.DropDownList("SabTvCategory", new SelectList(new List<string> { "TV" }))
<script>
var sabCategoryUrl = '../Command/GetSabnzbdCategories';
$('#SabTvCategory').focus(function () {
$.ajax({
type: "POST",
url: sabCategoryUrl,
data: jQuery.param({ host: '192.168.5.55', port: 2222, apiKey: '5c770e3197e4fe763423ee7c392c25d1', username: 'admin', password: 'pass' }),
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>