SABnzbd settings will now dynamically get the categories available from SABnzbd when the category drop-box gets focus, it will use values on the page so there is no need to save your settings first.

This commit is contained in:
Mark McDowall 2011-08-26 10:45:59 -07:00
commit 1d983801e8
13 changed files with 228 additions and 26 deletions

View file

@ -1,9 +1,38 @@
<img src='../../Content/Images/ignoredNeutral.png' class='ignoredEpisodesMaster ignoreEpisode' id='master' value='10'/>
@Html.DropDownList("SabTvCategory", new SelectList(new List<string> { "TV" }))
<script>
$(".ignoreEpisode").live("click", function () {
var toggle = $(this);
var value = $(this).attr('value');
var test = 0;
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>