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

81 lines
2.7 KiB
JavaScript
Raw Normal View History

2014-05-21 11:38:12 -07:00
(function ($, window, document) {
2014-05-21 12:33:46 -07:00
function loadForm(page, userId, displayPreferences) {
2014-05-21 11:38:12 -07:00
2014-07-21 18:29:06 -07:00
$('#selectThemeSong', page).val(store.getItem('enableThemeSongs-' + userId) || '').selectmenu("refresh");
$('#selectBackdrop', page).val(store.getItem('enableBackdrops-' + userId) || '').selectmenu("refresh");
2014-05-21 12:33:46 -07:00
$('#selectHomeSection1', page).val(displayPreferences.CustomPrefs.home0 || '').selectmenu("refresh");
$('#selectHomeSection2', page).val(displayPreferences.CustomPrefs.home1 || '').selectmenu("refresh");
$('#selectHomeSection3', page).val(displayPreferences.CustomPrefs.home2 || '').selectmenu("refresh");
$('#selectHomeSection4', page).val(displayPreferences.CustomPrefs.home3 || '').selectmenu("refresh");
2014-05-21 11:38:12 -07:00
Dashboard.hideLoadingMsg();
}
2014-05-21 12:33:46 -07:00
function saveUser(page, userId, displayPreferences) {
2014-07-21 18:29:06 -07:00
store.setItem('enableThemeSongs-' + userId, $('#selectThemeSong', page).val());
store.setItem('enableBackdrops-' + userId, $('#selectBackdrop', page).val());
2014-05-21 12:33:46 -07:00
displayPreferences.CustomPrefs.home0 = $('#selectHomeSection1', page).val();
displayPreferences.CustomPrefs.home1 = $('#selectHomeSection2', page).val();
displayPreferences.CustomPrefs.home2 = $('#selectHomeSection3', page).val();
displayPreferences.CustomPrefs.home3 = $('#selectHomeSection4', page).val();
2014-05-21 11:38:12 -07:00
2014-05-21 12:33:46 -07:00
ApiClient.updateDisplayPreferences('home', displayPreferences, userId, 'webclient').done(function () {
2014-05-21 11:38:12 -07:00
2014-05-30 12:23:56 -07:00
Dashboard.alert(Globalize.translate('SettingsSaved'));
2014-07-21 18:29:06 -07:00
2014-05-21 12:33:46 -07:00
});
2014-05-21 11:38:12 -07:00
}
function onSubmit() {
var page = $(this).parents('.page');
Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
2014-05-21 12:33:46 -07:00
ApiClient.getDisplayPreferences('home', userId, 'webclient').done(function (result) {
2014-05-21 11:38:12 -07:00
2014-05-21 12:33:46 -07:00
saveUser(page, userId, result);
2014-05-21 11:38:12 -07:00
});
// Disable default form submission
return false;
}
$(document).on('pageinit', "#webClientPreferencesPage", function () {
var page = this;
}).on('pagebeforeshow', "#webClientPreferencesPage", function () {
var page = this;
Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
2014-05-21 12:33:46 -07:00
ApiClient.getDisplayPreferences('home', userId, 'webclient').done(function (result) {
2014-05-21 11:38:12 -07:00
2014-05-21 12:33:46 -07:00
loadForm(page, userId, result);
2014-05-21 11:38:12 -07:00
});
2014-08-07 21:36:51 -07:00
// See backrops.js for comments on this
if ($.browser.msie) {
$('.fldEnableBackdrops', page).hide();
} else {
$('.fldEnableBackdrops', page).show();
}
2014-05-21 11:38:12 -07:00
});
window.WebClientPreferencesPage = {
onSubmit: onSubmit
};
})(jQuery, window, document);