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
|
2015-12-14 08:43:03 -07:00
|
|
|
|
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(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')
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}).then(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
|
|
|
|
|
2015-12-14 08:43:03 -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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-22 20:46:03 -07:00
|
|
|
|
function reloadData(page, config, cultures, countries) {
|
2013-09-30 08:41:18 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
populateLanguages(page.querySelector('#selectLanguage'), cultures);
|
|
|
|
|
populateCountries(page.querySelector('#selectCountry'), countries);
|
2013-09-30 08:41:18 -07:00
|
|
|
|
|
2015-09-03 10:01:51 -07:00
|
|
|
|
$('#selectLanguage', page).val(config.PreferredMetadataLanguage);
|
|
|
|
|
$('#selectCountry', page).val(config.MetadataCountryCode);
|
2013-09-30 08:41:18 -07:00
|
|
|
|
|
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
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
Promise.all([promise1, promise2, promise3]).then(function (responses) {
|
2013-12-22 20:46:03 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
reloadData(page, responses[0], responses[1], responses[2]);
|
2013-09-30 08:41:18 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
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);
|