2014-01-12 09:55:38 -07:00
|
|
|
|
(function ($, document, window) {
|
|
|
|
|
|
2015-07-23 06:23:22 -07:00
|
|
|
|
function loadPage(page, config) {
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-07-23 06:23:22 -07:00
|
|
|
|
$('.liveTvSettingsForm', page).show();
|
|
|
|
|
$('.noLiveTvServices', page).hide();
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
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
|
|
|
|
|
2015-07-23 07:58:27 -07:00
|
|
|
|
$('#txtRecordingPath', page).val(config.RecordingPath || '');
|
|
|
|
|
|
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();
|
2015-07-23 07:58:27 -07:00
|
|
|
|
config.RecordingPath = $('#txtRecordingPath', form).val() || null;
|
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-07-23 07:58:27 -07:00
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-06-06 19:51:04 -07:00
|
|
|
|
$('.liveTvSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-07-23 07:58:27 -07:00
|
|
|
|
$('#btnSelectRecordingPath', page).on("click.selectDirectory", function () {
|
|
|
|
|
|
|
|
|
|
var picker = new DirectoryBrowser(page);
|
|
|
|
|
|
|
|
|
|
picker.show({
|
|
|
|
|
|
|
|
|
|
callback: function (path) {
|
|
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
|
$('#txtRecordingPath', page).val(path);
|
|
|
|
|
}
|
|
|
|
|
picker.close();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
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-07-23 06:23:22 -07:00
|
|
|
|
ApiClient.getNamedConfiguration("livetv").done(function (config) {
|
2014-01-12 09:55:38 -07:00
|
|
|
|
|
2015-07-23 06:23:22 -07:00
|
|
|
|
loadPage(page, config);
|
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);
|