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

87 lines
2.2 KiB
JavaScript
Raw Normal View History

2013-09-05 10:05:39 -07:00
(function ($, document) {
function save(page) {
Dashboard.showLoadingMsg();
2014-11-14 19:31:03 -07:00
var apiClient = ApiClient;
2014-02-26 20:57:37 -07:00
// After saving chapter task, now save server config
2014-11-14 19:31:03 -07:00
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).done(function (config) {
2013-09-05 10:05:39 -07:00
2014-02-26 20:57:37 -07:00
config.PreferredMetadataLanguage = $('#selectLanguage', page).val();
config.MetadataCountryCode = $('#selectCountry', page).val();
2015-07-30 07:34:46 -07:00
config.SaveLocalMeta = page.querySelector('.chkSaveLocalMetadata').checked;
config.EnableInternetProviders = page.querySelector('.chkEnableInternetProviders').checked;
2014-03-05 22:17:13 -07:00
2014-11-14 19:31:03 -07:00
apiClient.ajax({
type: 'POST',
data: config,
url: apiClient.getUrl('Startup/Configuration')
}).done(function () {
2013-09-05 10:05:39 -07:00
2014-02-26 20:57:37 -07:00
navigateToNextPage();
2013-09-05 10:05:39 -07:00
2013-12-22 20:46:03 -07:00
});
});
}
2013-09-05 10:05:39 -07:00
2013-12-22 20:46:03 -07:00
function reloadData(page, config, cultures, countries) {
2013-12-28 09:58:13 -07:00
Dashboard.populateLanguages($('#selectLanguage', page), cultures);
Dashboard.populateCountries($('#selectCountry', page), countries);
2015-09-03 10:01:51 -07:00
$('#selectLanguage', page).val(config.PreferredMetadataLanguage);
$('#selectCountry', page).val(config.MetadataCountryCode);
2013-12-22 20:46:03 -07:00
Dashboard.hideLoadingMsg();
}
function reload(page) {
Dashboard.showLoadingMsg();
2014-11-14 19:31:03 -07:00
var apiClient = ApiClient;
var promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration'));
var promise2 = apiClient.getCultures();
var promise3 = apiClient.getCountries();
2013-12-22 20:46:03 -07:00
$.when(promise1, promise2, promise3).done(function (response1, response2, response3) {
reloadData(page, response1[0], response2[0], response3[0]);
});
}
2013-12-22 20:46:03 -07:00
function navigateToNextPage() {
2013-09-05 10:05:39 -07:00
2015-08-20 13:54:00 -07:00
Dashboard.navigate('wizardlivetvtuner.html');
2013-12-22 20:46:03 -07:00
}
2013-09-05 10:05:39 -07:00
2015-05-18 18:46:31 -07:00
function onSubmit() {
var form = this;
2013-09-05 10:05:39 -07:00
2015-05-18 18:46:31 -07:00
save(form);
2013-09-05 10:05:39 -07:00
2015-05-18 18:46:31 -07:00
return false;
}
2013-12-22 20:46:03 -07:00
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#wizardSettingsPage", function () {
2013-12-22 20:46:03 -07:00
2015-05-23 13:44:15 -07:00
var page = this;
2015-05-18 18:46:31 -07:00
$('.wizardSettingsForm', page).off('submit', onSubmit).on('submit', onSubmit);
2013-12-22 20:46:03 -07:00
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#wizardSettingsPage", function () {
2013-12-22 20:46:03 -07:00
2015-05-18 18:46:31 -07:00
var page = this;
2013-12-22 20:46:03 -07:00
2015-05-18 18:46:31 -07:00
reload(page);
});
2013-12-22 20:46:03 -07:00
2013-09-05 10:05:39 -07:00
})(jQuery, document, window);