jellyfin-web/dashboard-ui/scripts/livetvsettings.js

67 lines
1.8 KiB
JavaScript
Raw Normal View History

2014-01-12 09:55:38 -07:00
(function ($, document, window) {
2014-01-14 13:03:35 -07:00
function loadPage(page, config, liveTvInfo) {
2014-01-12 09:55:38 -07:00
2014-01-17 11:23:00 -07:00
if (liveTvInfo.IsEnabled) {
2014-01-12 09:55:38 -07:00
$('.liveTvSettingsForm', page).show();
$('.noLiveTvServices', page).hide();
} else {
$('.liveTvSettingsForm', page).hide();
$('.noLiveTvServices', page).show();
}
$('#selectGuideDays', page).val(config.LiveTvOptions.GuideDays || '').selectmenu('refresh');
2014-01-16 15:49:31 -07:00
var serviceOptions = liveTvInfo.Services.map(function (s) {
return '<option value="' + s.Name + '">' + s.Name + '</option>';
});
2014-05-17 11:37:40 -07:00
$('#selectActiveService', page).html(serviceOptions).val(config.LiveTvOptions.ActiveService || '').selectmenu('refresh');
2014-01-16 15:49:31 -07:00
2014-01-12 09:55:38 -07:00
Dashboard.hideLoadingMsg();
}
$(document).on('pageshow', "#liveTvSettingsPage", function () {
Dashboard.showLoadingMsg();
var page = this;
var promise1 = ApiClient.getServerConfiguration();
2014-01-14 13:03:35 -07:00
var promise2 = ApiClient.getLiveTvInfo();
2014-01-12 09:55:38 -07:00
$.when(promise1, promise2).done(function (response1, response2) {
loadPage(page, response1[0], response2[0]);
});
});
2014-01-16 15:49:31 -07:00
window.LiveTvSettingsPage = {
onSubmit: function () {
2014-01-12 09:55:38 -07:00
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getServerConfiguration().done(function (config) {
config.LiveTvOptions.GuideDays = $('#selectGuideDays', form).val() || null;
2014-05-17 11:37:40 -07:00
config.LiveTvOptions.ActiveService = $('#selectActiveService', form).val() || null;
2014-01-12 09:55:38 -07:00
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
}
};
})(jQuery, document, window);