jellyfin-web/dashboard-ui/scripts/livetvsettings.js
2015-06-06 22:51:04 -04:00

63 lines
1.7 KiB
JavaScript

(function ($, document, window) {
function loadPage(page, config, liveTvInfo) {
if (liveTvInfo.IsEnabled) {
$('.liveTvSettingsForm', page).show();
$('.noLiveTvServices', page).hide();
} else {
$('.liveTvSettingsForm', page).hide();
$('.noLiveTvServices', page).show();
}
$('#selectGuideDays', page).val(config.GuideDays || '').selectmenu('refresh');
$('#chkMovies', page).checked(config.EnableMovieProviders).checkboxradio("refresh");
Dashboard.hideLoadingMsg();
}
function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getNamedConfiguration("livetv").done(function (config) {
config.GuideDays = $('#selectGuideDays', form).val() || null;
config.EnableMovieProviders = $('#chkMovies', form).checked();
ApiClient.updateNamedConfiguration("livetv", config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
}
$(document).on('pageinitdepends', "#liveTvSettingsPage", function () {
$('.liveTvSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshowready', "#liveTvSettingsPage", function () {
Dashboard.showLoadingMsg();
var page = this;
var promise1 = ApiClient.getNamedConfiguration("livetv");
var promise2 = ApiClient.getLiveTvInfo();
$.when(promise1, promise2).done(function (response1, response2) {
loadPage(page, response1[0], response2[0]);
});
});
})(jQuery, document, window);