1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-29 03:15:19 +00:00
Radarr/NzbDrone.Web/Scripts/NzbDrone/qualitySettings.js

113 lines
3.3 KiB
JavaScript
Raw Normal View History

var deleteQualityProfileUrl = '../../Settings/DeleteQualityProfile';
$(document).on("click", "#addProfile", function (event) {
$.ajax({
url: this.href,
cache: false,
success: function (html) {
$("#profiles").append(html);
}
});
event.preventDefault();
});
2012-10-11 07:27:05 +00:00
$(document).on('click', '.delete-profile', function (e) {
var container = $(this).closest('.profileSection');
var id = $(container).attr('data-profile-id');
$.ajax({
type: "POST",
url: deleteQualityProfileUrl,
data: jQuery.param({ profileId: id }),
success: function (data, textStatus, jqXHR) {
$(container).remove();
removeOption(id);
}
});
e.preventDefault();
});
function renameOption(text, value) {
$("#DefaultQualityProfileId option[value='" + value + "']").html(text);
}
function addOption(text, value) {
var myCombo = $('#DefaultQualityProfileId');
var exists = $("#DefaultQualityProfileId option[value='" + value + "']");
if (exists.length == 0)
myCombo.append($('\<option\> \</option\>').val(value).html(text));
}
function removeOption(value) {
$("#DefaultQualityProfileId option[value='" + value + "']").remove();
}
function getProfileId(obj) {
2012-10-11 07:27:05 +00:00
var parentProfileSection = $(obj).closest('.profileSection');
return parentProfileSection.attr('data-profile-id');
}
function getCleanId(obj) {
var parentProfileSection = $(obj).parents('.profileSection');
return parentProfileSection.children('.cleanId').val();
}
$(document).on('keyup', '.profileName_textbox', function () {
var value = $(this).val();
2012-10-11 07:27:05 +00:00
$(this).closest('.profileSection').find('.titleText').text(value);
var profileId = getProfileId(this);
2012-10-11 07:27:05 +00:00
renameOption(value, profileId);
}).keyup();
$(document).on('click', '.quality-selectee', function () {
var id = $(this).attr('id');
var cleanId = getCleanId(this);
var cutoff = '#' + cleanId + '_Cutoff';
var name = jQuery('[for="' + id + '"]').children('.ui-button-text').text();
2012-10-14 23:09:07 +00:00
var qualityId = $(this).attr('data-quality-id');
//Remove 'Unknown'
$(cutoff + ' option').each(function () { if ($(this).text().indexOf('Unknown') > -1) $(cutoff + ' option').remove(':contains("' + $(this).text() + '")'); });
//Add option to cutoff SelectList
if ($(this).attr('checked')) {
2012-10-14 23:09:07 +00:00
$('<option>' + name + '</option>').val(qualityId).appendTo(cutoff);
}
//Remove option from cutoff SelectList
else {
2012-10-14 23:09:07 +00:00
$(cutoff).find('option[value="' + qualityId + '"]').remove();
}
});
var sliderOptions = {
min: 0,
max: 200,
value: 0,
step: 1,
create: function (event, ui) {
var startingValue = $(this).siblings('.slider-value').val();
$(this).siblings('.30-minute').text(startingValue * 30);
$(this).siblings('.60-minute').text(startingValue * 60);
},
slide: function (event, ui) {
$(this).siblings('.slider-value').val(ui.value);
$(this).siblings('.30-minute').text(ui.value * 30);
$(this).siblings('.60-minute').text(ui.value * 60);
}
};
function setupSliders() {
$(".slider").each(function () {
var localOptions = sliderOptions;
localOptions["value"] = $(this).siblings('.slider-value').val();
$(this).empty().slider(localOptions);
});
}