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();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-27 15:01:29 -07:00
|
|
|
|
$('#selectGuideDays', page).val(config.GuideDays || '').selectmenu('refresh');
|
2014-01-16 15:49:31 -07:00
|
|
|
|
|
2015-03-14 13:00:32 -07:00
|
|
|
|
$('#chkMovies', page).checked(config.EnableMovieProviders).checkboxradio("refresh");
|
2014-01-16 15:49:31 -07:00
|
|
|
|
|
2014-01-12 09:55:38 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
function onSubmit() {
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
var form = this;
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
ApiClient.getNamedConfiguration("livetv").done(function (config) {
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
config.GuideDays = $('#selectGuideDays', form).val() || null;
|
|
|
|
|
config.EnableMovieProviders = $('#chkMovies', form).checked();
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
ApiClient.updateNamedConfiguration("livetv", config).done(Dashboard.processServerConfigurationUpdateResult);
|
|
|
|
|
});
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
$(document).on('pageinitdepends', "#liveTvSettingsPage", function () {
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
$('.liveTvSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
}).on('pageshowready', "#liveTvSettingsPage", function () {
|
2014-01-16 15:49:31 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-01-16 15:49:31 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
var page = this;
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
var promise1 = ApiClient.getNamedConfiguration("livetv");
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
var promise2 = ApiClient.getLiveTvInfo();
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
$.when(promise1, promise2).done(function (response1, response2) {
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
loadPage(page, response1[0], response2[0]);
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|