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

75 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-07-29 19:35:11 -07:00
(function ($, window, document) {
function loadForm(page, user) {
2015-08-10 17:14:15 -07:00
page.querySelector('#txtSyncPath').value = AppSettings.syncPath();
2015-08-12 14:39:02 -07:00
page.querySelector('#chkWifi').checked = AppSettings.syncOnlyOnWifi();
2015-08-14 07:42:40 -07:00
page.querySelector('#chkSyncLosslessAudio').checked = AppSettings.syncLosslessAudio();
2015-07-29 19:35:11 -07:00
Dashboard.hideLoadingMsg();
}
function saveUser(page, user) {
2015-08-10 17:14:15 -07:00
AppSettings.syncPath(page.querySelector('#txtSyncPath').value);
2015-08-12 14:39:02 -07:00
AppSettings.syncOnlyOnWifi(page.querySelector('#chkWifi').checked);
2015-08-14 07:42:40 -07:00
AppSettings.syncLosslessAudio(page.querySelector('#chkSyncLosslessAudio').checked);
2015-08-12 14:39:02 -07:00
2015-07-29 19:35:11 -07:00
Dashboard.hideLoadingMsg();
Dashboard.alert(Globalize.translate('SettingsSaved'));
}
function onSubmit() {
var page = $(this).parents('.page')[0];
Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
ApiClient.getUser(userId).done(function (user) {
saveUser(page, user);
});
// Disable default form submission
return false;
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#syncPreferencesPage", function () {
2015-07-29 19:35:11 -07:00
var page = this;
2015-08-08 09:16:34 -07:00
$('form', page).off('submit', onSubmit).on('submit', onSubmit);
2015-07-29 19:35:11 -07:00
$('.btnSelectSyncPath', page).on('click', function () {
require(['nativedirectorychooser'], function () {
NativeDirectoryChooser.chooseDirectory().done(function (path) {
$('#txtSyncPath', page).val(path);
});
});
});
}).on('pageshowready', "#syncPreferencesPage", function () {
var page = this;
Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
ApiClient.getUser(userId).done(function (user) {
loadForm(page, user);
});
2015-09-11 09:26:06 -07:00
if (AppInfo.supportsSyncPathSetting) {
page.querySelector('.fldSyncPath').classList.remove('hide');
} else {
page.querySelector('.fldSyncPath').classList.add('hide');
}
2015-07-29 19:35:11 -07:00
});
})(jQuery, window, document);