1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/mypreferenceswebclient.js

141 lines
4.9 KiB
JavaScript
Raw Normal View History

2014-05-21 14:38:12 -04:00
(function ($, window, document) {
2014-05-21 15:33:46 -04:00
function loadForm(page, userId, displayPreferences) {
2014-05-21 14:38:12 -04:00
2014-09-16 21:38:50 -04:00
$('#selectMaxBitrate', page).val(AppSettings.maxStreamingBitrate()).selectmenu("refresh");
2015-04-26 00:39:40 -04:00
$('#selectMaxChromecastBitrate', page).val(AppSettings.maxChromecastBitrate()).selectmenu("refresh");
2014-09-16 21:38:50 -04:00
2015-05-25 13:32:22 -04:00
$('#chkExternalVideoPlayer', page).checked(AppSettings.enableExternalPlayers()).checkboxradio("refresh");
2014-09-15 23:33:30 -04:00
2015-05-20 13:29:26 -04:00
$('#selectThemeSong', page).val(appStorage.getItem('enableThemeSongs-' + userId) || '').selectmenu("refresh");
$('#selectBackdrop', page).val(appStorage.getItem('enableBackdrops-' + userId) || '').selectmenu("refresh");
2014-05-21 15:33:46 -04: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 14:38:12 -04:00
2015-03-14 21:58:06 -04:00
$('#chkEnableLibraryTileNames', page).checked(displayPreferences.CustomPrefs.enableLibraryTileNames != '0').checkboxradio("refresh");
2014-05-21 14:38:12 -04:00
Dashboard.hideLoadingMsg();
}
2014-05-21 15:33:46 -04:00
function saveUser(page, userId, displayPreferences) {
2015-05-20 13:29:26 -04:00
appStorage.setItem('enableThemeSongs-' + userId, $('#selectThemeSong', page).val());
appStorage.setItem('enableBackdrops-' + userId, $('#selectBackdrop', page).val());
2014-05-21 15:33:46 -04: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();
2015-03-14 21:58:06 -04:00
displayPreferences.CustomPrefs.enableLibraryTileNames = $('#chkEnableLibraryTileNames', page).checked() ? '1' : '0';
2014-05-21 14:38:12 -04:00
2014-05-21 15:33:46 -04:00
ApiClient.updateDisplayPreferences('home', displayPreferences, userId, 'webclient').done(function () {
2014-05-21 14:38:12 -04:00
2014-05-30 15:23:56 -04:00
Dashboard.alert(Globalize.translate('SettingsSaved'));
2014-07-21 21:29:06 -04:00
2014-05-21 15:33:46 -04:00
});
2014-05-21 14:38:12 -04:00
}
function onSubmit() {
var page = $(this).parents('.page');
Dashboard.showLoadingMsg();
2015-05-25 13:32:22 -04:00
AppSettings.enableExternalPlayers($('#chkExternalVideoPlayer', page).checked());
2014-09-15 23:33:30 -04:00
2014-09-16 21:38:50 -04:00
AppSettings.maxStreamingBitrate($('#selectMaxBitrate', page).val());
2015-04-26 00:39:40 -04:00
AppSettings.maxChromecastBitrate($('#selectMaxChromecastBitrate', page).val());
2014-09-16 21:38:50 -04:00
2014-05-21 14:38:12 -04:00
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
2014-05-21 15:33:46 -04:00
ApiClient.getDisplayPreferences('home', userId, 'webclient').done(function (result) {
2014-05-21 14:38:12 -04:00
2014-05-21 15:33:46 -04:00
saveUser(page, userId, result);
2014-05-21 14:38:12 -04:00
});
// Disable default form submission
return false;
}
2015-05-26 15:53:12 -04:00
$(document).on('pageshowready', "#webClientPreferencesPage", function () {
2014-05-21 14:38:12 -04:00
var page = this;
Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
2014-05-21 15:33:46 -04:00
ApiClient.getDisplayPreferences('home', userId, 'webclient').done(function (result) {
2014-05-21 14:38:12 -04:00
2014-05-21 15:33:46 -04:00
loadForm(page, userId, result);
2014-05-21 14:38:12 -04:00
});
2014-08-08 00:36:51 -04:00
2015-05-04 10:35:38 -04:00
$('.fldEnableBackdrops', page).show();
2015-05-07 18:27:01 -04:00
if (Dashboard.isRunningInCordova()) {
$('.homePageConfigurationSection', page).hide();
} else {
$('.homePageConfigurationSection', page).show();
}
2015-05-26 15:53:12 -04:00
if (AppInfo.hasKnownExternalPlayerSupport) {
$('.labelNativeExternalPlayers', page).show();
$('.labelGenericExternalPlayers', page).hide();
} else {
$('.labelGenericExternalPlayers', page).show();
$('.labelNativeExternalPlayers', page).hide();
}
2014-05-21 14:38:12 -04:00
});
window.WebClientPreferencesPage = {
onSubmit: onSubmit
};
2014-09-16 21:38:50 -04:00
})(jQuery, window, document);
(function (window, store) {
window.AppSettings = {
maxStreamingBitrate: function (val) {
if (val != null) {
store.setItem('preferredVideoBitrate', val);
}
return parseInt(store.getItem('preferredVideoBitrate') || '') || 1500000;
2015-04-26 00:39:40 -04:00
},
maxChromecastBitrate: function (val) {
if (val != null) {
store.setItem('chromecastBitrate', val);
}
return parseInt(store.getItem('chromecastBitrate') || '') || 3000000;
2015-05-25 13:32:22 -04:00
},
enableExternalPlayers: function (val) {
if (val != null) {
store.setItem('externalplayers', val.toString());
}
return store.getItem('externalplayers') == 'true';
2015-05-26 15:53:12 -04:00
},
enableItemPreviews: function (val) {
if (val != null) {
store.setItem('enableItemPreviews', val.toString());
}
return store.getItem('enableItemPreviews') != 'false';
2014-09-16 21:38:50 -04:00
}
};
2015-05-20 13:29:26 -04:00
})(window, window.appStorage);