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

100 lines
2.4 KiB
JavaScript
Raw Normal View History

2015-08-20 13:54:00 -07:00
(function ($, document) {
function save(page) {
Dashboard.showLoadingMsg();
var apiClient = ApiClient;
// After saving chapter task, now save server config
2015-12-14 08:43:03 -07:00
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
2015-08-20 13:54:00 -07:00
config.LiveTvTunerType = $('#selectTunerType', page).val();
config.LiveTvTunerPath = $('.txtDevicePath', page).val();
apiClient.ajax({
type: 'POST',
data: config,
url: apiClient.getUrl('Startup/Configuration')
2015-12-14 08:43:03 -07:00
}).then(function () {
2015-08-20 13:54:00 -07:00
Dashboard.hideLoadingMsg();
2015-08-21 19:59:10 -07:00
navigateToNextPage(config);
2015-08-22 11:15:35 -07:00
2015-12-14 08:43:03 -07:00
}, function () {
2015-08-22 11:15:35 -07:00
Dashboard.hideLoadingMsg();
Dashboard.alert({
message: Globalize.translate('ErrorSavingTvProvider')
});
2015-08-20 13:54:00 -07:00
});
});
}
function reload(page) {
Dashboard.showLoadingMsg();
var apiClient = ApiClient;
2015-12-14 08:43:03 -07:00
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
2015-08-20 13:54:00 -07:00
2015-09-03 10:01:51 -07:00
$('#selectTunerType', page).val(config.LiveTvTunerType || 'hdhomerun');
2015-08-20 13:54:00 -07:00
page.querySelector('.txtDevicePath').value = config.LiveTvTunerPath || '';
Dashboard.hideLoadingMsg();
});
}
2015-08-21 19:59:10 -07:00
function navigateToNextPage(config) {
if (config.LiveTvTunerPath && config.LiveTvTunerType) {
Dashboard.navigate('wizardlivetvguide.html');
} else {
skip();
}
2015-08-20 13:54:00 -07:00
}
function skip() {
var apiClient = ApiClient;
2015-12-14 08:43:03 -07:00
apiClient.getJSON(apiClient.getUrl('Startup/Info')).then(function (info) {
2015-08-20 13:54:00 -07:00
if (info.SupportsRunningAsService) {
Dashboard.navigate('wizardservice.html');
} else {
Dashboard.navigate('wizardagreement.html');
}
});
}
function onSubmit() {
var form = this;
save(form);
return false;
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#wizardTunerPage", function () {
2015-08-20 13:54:00 -07:00
var page = this;
$('form', page).off('submit', onSubmit).on('submit', onSubmit);
$('.btnSkip', page).on('click', skip);
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#wizardTunerPage", function () {
2015-08-20 13:54:00 -07:00
var page = this;
reload(page);
});
})(jQuery, document, window);