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-15 20:33:30 -07:00
|
|
|
|
var externalPlayers = JSON.parse(store.getItem('externalplayers') || '[]');
|
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
$('#selectMaxBitrate', page).val(AppSettings.maxStreamingBitrate()).selectmenu("refresh");
|
|
|
|
|
|
2014-09-15 20:33:30 -07:00
|
|
|
|
$('.chkExternalPlayer', page).each(function () {
|
|
|
|
|
|
|
|
|
|
var chk = this;
|
|
|
|
|
chk.checked = externalPlayers.filter(function (p) {
|
|
|
|
|
|
|
|
|
|
return p.name == chk.getAttribute('data-name');
|
|
|
|
|
|
|
|
|
|
}).length > 0;
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
|
|
|
|
|
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");
|
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-03-14 18:58:06 -07:00
|
|
|
|
$('#chkEnableLibraryTileNames', page).checked(displayPreferences.CustomPrefs.enableLibraryTileNames != '0').checkboxradio("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();
|
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();
|
|
|
|
|
|
2014-09-15 20:33:30 -07:00
|
|
|
|
var externalPlayers = $('.chkExternalPlayer:checked', page).get().map(function (i) {
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
name: i.getAttribute('data-name'),
|
|
|
|
|
scheme: i.getAttribute('data-scheme')
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
store.setItem('externalplayers', JSON.stringify(externalPlayers));
|
|
|
|
|
|
2014-09-16 18:38:50 -07:00
|
|
|
|
AppSettings.maxStreamingBitrate($('#selectMaxBitrate', 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(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
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-16 18:38:50 -07: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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})(window, window.store);
|