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

110 lines
3.3 KiB
JavaScript
Raw Normal View History

2015-06-08 14:32:20 -07:00
(function () {
2013-02-20 18:33:05 -07:00
2015-06-08 14:32:20 -07:00
function load(page, config, allCultures, allCountries) {
2013-02-20 18:33:05 -07:00
if (!config || !allCultures || !allCountries) {
return;
}
2014-02-26 20:57:37 -07:00
$('#chkEnableInternetProviders', page).checked(config.EnableInternetProviders).checkboxradio("refresh");
2013-02-20 18:33:05 -07:00
$('#chkSaveLocal', page).checked(config.SaveLocalMeta).checkboxradio("refresh");
2015-09-03 10:01:51 -07:00
$('#selectLanguage', page).val(config.PreferredMetadataLanguage);
$('#selectCountry', page).val(config.MetadataCountryCode);
2013-02-20 18:33:05 -07:00
2015-09-03 10:01:51 -07:00
$('#selectImageSavingConvention', page).val(config.ImageSavingConvention);
2014-02-02 06:36:31 -07:00
2013-02-20 18:33:05 -07:00
Dashboard.hideLoadingMsg();
2015-06-08 14:32:20 -07:00
}
function onSubmit() {
2013-02-20 18:33:05 -07:00
var form = this;
2013-04-16 21:58:32 -07:00
Dashboard.showLoadingMsg();
2015-11-27 18:18:15 -07:00
ApiClient.getServerConfiguration().then(function (config) {
2013-02-20 18:33:05 -07:00
2014-02-02 06:36:31 -07:00
config.ImageSavingConvention = $('#selectImageSavingConvention', form).val();
2014-02-26 20:57:37 -07:00
config.EnableInternetProviders = $('#chkEnableInternetProviders', form).checked();
2013-02-20 18:33:05 -07:00
config.SaveLocalMeta = $('#chkSaveLocal', form).checked();
config.PreferredMetadataLanguage = $('#selectLanguage', form).val();
config.MetadataCountryCode = $('#selectCountry', form).val();
2015-11-28 01:07:44 -07:00
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult);
2013-02-20 18:33:05 -07:00
});
// Disable default form submission
return false;
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#metadataConfigurationPage", function () {
2015-06-08 14:32:20 -07:00
Dashboard.showLoadingMsg();
$('.metadataConfigurationForm').off('submit', onSubmit).on('submit', onSubmit);
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#metadataConfigurationPage", function () {
2015-06-08 14:32:20 -07:00
Dashboard.showLoadingMsg();
var page = this;
var config;
var allCultures;
var allCountries;
2015-11-27 18:18:15 -07:00
ApiClient.getServerConfiguration().then(function (result) {
2015-06-08 14:32:20 -07:00
config = result;
load(page, config, allCultures, allCountries);
});
2015-11-29 12:44:15 -07:00
function populateLanguages(select, languages) {
var html = "";
html += "<option value=''></option>";
for (var i = 0, length = languages.length; i < length; i++) {
var culture = languages[i];
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + "</option>";
}
select.innerHTML = html;
}
function populateCountries(select, allCountries) {
var html = "";
html += "<option value=''></option>";
for (var i = 0, length = allCountries.length; i < length; i++) {
var culture = allCountries[i];
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + "</option>";
}
select.innerHTML = html;
}
2015-11-28 01:07:44 -07:00
ApiClient.getCultures().then(function (result) {
2015-06-08 14:32:20 -07:00
2015-11-29 12:44:15 -07:00
populateLanguages(page.querySelector('#selectLanguage'), result);
2015-06-08 14:32:20 -07:00
allCultures = result;
load(page, config, allCultures, allCountries);
});
2015-11-28 01:07:44 -07:00
ApiClient.getCountries().then(function (result) {
2015-06-08 14:32:20 -07:00
2015-11-29 12:44:15 -07:00
populateCountries(page.querySelector('#selectCountry'), result);
2015-06-08 14:32:20 -07:00
allCountries = result;
load(page, config, allCultures, allCountries);
});
});
})();