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

64 lines
2.0 KiB
JavaScript
Raw Normal View History

2014-04-19 22:21:08 -07:00
(function ($, document, window) {
function loadPage(page, config, users) {
2014-06-29 10:35:05 -07:00
$('#chkEnableServer', page).checked(config.EnableServer).checkboxradio("refresh");
$('#chkBlastAliveMessages', page).checked(config.BlastAliveMessages).checkboxradio("refresh");
$('#txtBlastInterval', page).val(config.BlastAliveMessageIntervalSeconds);
2014-04-19 22:21:08 -07:00
2015-03-04 21:13:08 -07:00
$('#chkEnableEnhancedMovies', page).checked(config.EnableEnhancedMovies).checkboxradio("refresh");
2014-04-19 22:21:08 -07:00
var usersHtml = users.map(function (u) {
return '<option value="' + u.Id + '">' + u.Name + '</option>';
}).join('');
2014-06-29 10:35:05 -07:00
$('#selectUser', page).html(usersHtml).val(config.DefaultUserId || '').selectmenu("refresh");
2014-04-19 22:21:08 -07:00
Dashboard.hideLoadingMsg();
}
$(document).on('pageshow', "#dlnaServerSettingsPage", function () {
Dashboard.showLoadingMsg();
var page = this;
2014-06-29 10:35:05 -07:00
var promise1 = ApiClient.getNamedConfiguration("dlna");
2014-04-19 22:21:08 -07:00
var promise2 = ApiClient.getUsers();
$.when(promise1, promise2).done(function (response1, response2) {
loadPage(page, response1[0], response2[0]);
});
});
function onSubmit() {
Dashboard.showLoadingMsg();
var form = this;
2014-06-29 10:35:05 -07:00
ApiClient.getNamedConfiguration("dlna").done(function (config) {
2014-04-19 22:21:08 -07:00
2014-06-29 10:35:05 -07:00
config.EnableServer = $('#chkEnableServer', form).checked();
config.BlastAliveMessages = $('#chkBlastAliveMessages', form).checked();
config.BlastAliveMessageIntervalSeconds = $('#txtBlastInterval', form).val();
config.DefaultUserId = $('#selectUser', form).val();
2014-04-19 22:21:08 -07:00
2015-03-04 21:13:08 -07:00
config.EnableEnhancedMovies = $('#chkEnableEnhancedMovies', form).checked();
2014-06-29 10:35:05 -07:00
ApiClient.updateNamedConfiguration("dlna", config).done(Dashboard.processServerConfigurationUpdateResult);
2014-04-19 22:21:08 -07:00
});
// Disable default form submission
return false;
}
window.DlnaServerSettingsPage = {
onSubmit: onSubmit
};
})(jQuery, document, window);