2014-06-29 20:04:50 -07:00
|
|
|
|
(function ($, document, window) {
|
|
|
|
|
|
|
|
|
|
var metadataKey = "xbmcmetadata";
|
2015-06-07 18:23:56 -07:00
|
|
|
|
|
2014-06-29 20:04:50 -07:00
|
|
|
|
function loadPage(page, config, users) {
|
|
|
|
|
|
|
|
|
|
var html = '<option value="" selected="selected"></option>';
|
|
|
|
|
|
|
|
|
|
html += users.map(function (user) {
|
|
|
|
|
return '<option value="' + user.Id + '">' + user.Name + '</option>';
|
|
|
|
|
}).join('');
|
|
|
|
|
|
2015-09-03 10:01:51 -07:00
|
|
|
|
$('#selectUser', page).html(html).val(config.UserId || '');
|
|
|
|
|
$('#selectReleaseDateFormat', page).val(config.ReleaseDateFormat);
|
2014-06-29 20:04:50 -07:00
|
|
|
|
$('#chkSaveImagePaths', page).checked(config.SaveImagePathsInNfo).checkboxradio('refresh');
|
|
|
|
|
$('#chkEnablePathSubstitution', page).checked(config.EnablePathSubstitution).checkboxradio('refresh');
|
2014-07-03 19:22:57 -07:00
|
|
|
|
$('#chkEnableExtraThumbs', page).checked(config.EnableExtraThumbsDuplication).checkboxradio('refresh');
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
function onSubmit() {
|
2014-06-29 20:04:50 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
var form = this;
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
ApiClient.getNamedConfiguration(metadataKey).done(function (config) {
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
config.UserId = $('#selectUser', form).val() || null;
|
|
|
|
|
config.ReleaseDateFormat = $('#selectReleaseDateFormat', form).val();
|
|
|
|
|
config.SaveImagePathsInNfo = $('#chkSaveImagePaths', form).checked();
|
|
|
|
|
config.EnablePathSubstitution = $('#chkEnablePathSubstitution', form).checked();
|
|
|
|
|
config.EnableExtraThumbsDuplication = $('#chkEnableExtraThumbs', form).checked();
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
ApiClient.updateNamedConfiguration(metadataKey, config).done(Dashboard.processServerConfigurationUpdateResult);
|
2014-06-29 20:04:50 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 07:01:59 -07:00
|
|
|
|
$(document).on('pageinit', "#metadataNfoPage", function () {
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
$('.metadataNfoForm').off('submit', onSubmit).on('submit', onSubmit);
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
}).on('pageshowready', "#metadataNfoPage", function () {
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
var page = this;
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
var promise1 = ApiClient.getUsers();
|
|
|
|
|
var promise2 = ApiClient.getNamedConfiguration(metadataKey);
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
$.when(promise1, promise2).done(function (response1, response2) {
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
2015-06-07 18:23:56 -07:00
|
|
|
|
loadPage(page, response2[0], response1[0]);
|
|
|
|
|
});
|
|
|
|
|
});
|
2014-06-29 20:04:50 -07:00
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|