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-09-16 18:38:50 -07:00
|
|
|
|
$('#selectMaxBitrate', page).val(AppSettings.maxStreamingBitrate()).selectmenu("refresh");
|
2015-04-25 21:39:40 -07:00
|
|
|
|
$('#selectMaxChromecastBitrate', page).val(AppSettings.maxChromecastBitrate()).selectmenu("refresh");
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
$('#chkExternalVideoPlayer', page).checked(AppSettings.enableExternalPlayers()).checkboxradio("refresh");
|
2014-09-15 20:33:30 -07:00
|
|
|
|
|
2015-05-20 10:29:26 -07:00
|
|
|
|
$('#selectThemeSong', page).val(appStorage.getItem('enableThemeSongs-' + userId) || '').selectmenu("refresh");
|
|
|
|
|
$('#selectBackdrop', page).val(appStorage.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");
|
2014-06-15 16:30:04 -07:00
|
|
|
|
$('#selectHomeSection4', page).val(displayPreferences.CustomPrefs.home3 || '').selectmenu("refresh");
|
2014-05-21 11:38:12 -07:00
|
|
|
|
|
2015-05-26 13:01:49 -07:00
|
|
|
|
$('#selectEnableItemPreviews', page).val(AppSettings.enableItemPreviews().toString().toLowerCase()).selectmenu("refresh");
|
|
|
|
|
|
2015-03-14 18:58:06 -07:00
|
|
|
|
$('#chkEnableLibraryTileNames', page).checked(displayPreferences.CustomPrefs.enableLibraryTileNames != '0').checkboxradio("refresh");
|
2015-06-07 20:16:42 -07:00
|
|
|
|
$('#chkEnableFullScreen', page).checked(AppSettings.enableFullScreen()).checkboxradio("refresh");
|
|
|
|
|
|
|
|
|
|
$('#chkEnableChromecastAc3', page).checked(AppSettings.enableChromecastAc3()).checkboxradio("refresh");
|
2015-03-14 18:58:06 -07:00
|
|
|
|
|
2015-06-09 21:01:14 -07:00
|
|
|
|
$('#txtSyncPath', page).val(AppSettings.syncPath());
|
|
|
|
|
|
2014-05-21 11:38:12 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-21 12:33:46 -07:00
|
|
|
|
function saveUser(page, userId, displayPreferences) {
|
|
|
|
|
|
2015-05-20 10:29:26 -07:00
|
|
|
|
appStorage.setItem('enableThemeSongs-' + userId, $('#selectThemeSong', page).val());
|
|
|
|
|
appStorage.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();
|
2014-06-15 16:30:04 -07:00
|
|
|
|
displayPreferences.CustomPrefs.home3 = $('#selectHomeSection4', page).val();
|
2015-03-14 18:58:06 -07:00
|
|
|
|
displayPreferences.CustomPrefs.enableLibraryTileNames = $('#chkEnableLibraryTileNames', page).checked() ? '1' : '0';
|
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();
|
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
AppSettings.enableExternalPlayers($('#chkExternalVideoPlayer', page).checked());
|
2014-09-15 20:33:30 -07:00
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
AppSettings.maxStreamingBitrate($('#selectMaxBitrate', page).val());
|
2015-04-25 21:39:40 -07:00
|
|
|
|
AppSettings.maxChromecastBitrate($('#selectMaxChromecastBitrate', page).val());
|
2014-09-16 18:38:50 -07:00
|
|
|
|
|
2015-05-26 13:01:49 -07:00
|
|
|
|
AppSettings.enableItemPreviews($('#selectEnableItemPreviews', page).val() == 'true');
|
2015-06-03 21:50:10 -07:00
|
|
|
|
AppSettings.enableFullScreen($('#chkEnableFullScreen', page).checked());
|
2015-05-26 13:01:49 -07:00
|
|
|
|
|
2015-06-07 20:16:42 -07:00
|
|
|
|
AppSettings.enableChromecastAc3($('#chkEnableChromecastAc3', page).checked());
|
|
|
|
|
|
2015-06-09 21:01:14 -07:00
|
|
|
|
AppSettings.syncPath($('#txtSyncPath', page).val());
|
|
|
|
|
|
2014-05-21 11:38:12 -07:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-27 22:51:48 -07:00
|
|
|
|
$(document).on('pageinitdepends', "#webClientPreferencesPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.webClientPreferencesForm', page).off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
|
|
2015-06-09 21:01:14 -07:00
|
|
|
|
$('.btnSelectSyncPath', page).on('click', function () {
|
|
|
|
|
|
|
|
|
|
require(['nativedirectorychooser'], function () {
|
|
|
|
|
NativeDirectoryChooser.chooseDirectory().done(function (path) {
|
|
|
|
|
$('#txtSyncPath', page).val(path);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-05-27 22:51:48 -07:00
|
|
|
|
}).on('pageshowready', "#webClientPreferencesPage", function () {
|
2014-05-21 11:38:12 -07:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2015-05-04 07:35:38 -07:00
|
|
|
|
$('.fldEnableBackdrops', page).show();
|
2015-05-07 15:27:01 -07:00
|
|
|
|
|
2015-05-28 16:37:43 -07:00
|
|
|
|
if (AppInfo.isNativeApp) {
|
2015-05-07 15:27:01 -07:00
|
|
|
|
$('.homePageConfigurationSection', page).hide();
|
|
|
|
|
} else {
|
|
|
|
|
$('.homePageConfigurationSection', page).show();
|
|
|
|
|
}
|
2015-05-26 12:53:12 -07:00
|
|
|
|
|
|
|
|
|
if (AppInfo.hasKnownExternalPlayerSupport) {
|
|
|
|
|
$('.labelNativeExternalPlayers', page).show();
|
|
|
|
|
$('.labelGenericExternalPlayers', page).hide();
|
|
|
|
|
} else {
|
|
|
|
|
$('.labelGenericExternalPlayers', page).show();
|
|
|
|
|
$('.labelNativeExternalPlayers', page).hide();
|
|
|
|
|
}
|
2015-06-03 21:50:10 -07:00
|
|
|
|
|
|
|
|
|
if (AppInfo.supportsFullScreen) {
|
|
|
|
|
$('.fldFullscreen', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.fldFullscreen', page).hide();
|
|
|
|
|
}
|
2015-06-09 21:01:14 -07:00
|
|
|
|
|
|
|
|
|
if (AppInfo.supportsSyncPathSetting) {
|
|
|
|
|
$('.fldSyncPath', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.fldSyncPath', page).hide();
|
|
|
|
|
}
|
2014-05-21 11:38:12 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-05-27 22:51:48 -07:00
|
|
|
|
})(jQuery, window, document);
|