2011-08-26 17:45:59 +00:00
|
|
|
@Html.DropDownList("SabTvCategory", new SelectList(new List<string> { "TV" }))
|
|
|
|
|
2011-08-20 03:02:47 +00:00
|
|
|
|
|
|
|
<script>
|
2011-08-26 17:45:59 +00:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
});
|
2011-08-20 03:02:47 +00:00
|
|
|
});
|
|
|
|
</script>
|