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

54 lines
2.2 KiB
JavaScript
Raw Normal View History

2016-08-22 13:47:16 -07:00
define(['apphost', 'listViewStyle'], function (appHost) {
2016-10-22 22:11:46 -07:00
'use strict';
2015-09-24 22:15:29 -07:00
2016-08-22 13:47:16 -07:00
return function (view, params) {
2015-09-24 22:15:29 -07:00
2016-08-22 13:47:16 -07:00
view.querySelector('.btnLogout').addEventListener('click', function () {
2015-09-24 22:15:29 -07:00
2016-08-22 13:47:16 -07:00
Dashboard.logout();
});
2015-09-24 22:15:29 -07:00
2016-08-22 13:47:16 -07:00
view.addEventListener('viewshow', function () {
2015-09-24 22:15:29 -07:00
2016-08-22 13:47:16 -07:00
var page = this;
2015-05-27 22:51:48 -07:00
2016-08-22 13:47:16 -07:00
var userId = params.userId || Dashboard.getCurrentUserId();
2015-05-27 22:51:48 -07:00
2016-08-22 13:47:16 -07:00
page.querySelector('.lnkDisplayPreferences').setAttribute('href', 'mypreferencesdisplay.html?userId=' + userId);
page.querySelector('.lnkLanguagePreferences').setAttribute('href', 'mypreferenceslanguages.html?userId=' + userId);
page.querySelector('.lnkHomeScreenPreferences').setAttribute('href', 'mypreferenceshome.html?userId=' + userId);
page.querySelector('.lnkMyProfile').setAttribute('href', 'myprofile.html?userId=' + userId);
page.querySelector('.lnkSync').setAttribute('href', 'mysyncsettings.html?userId=' + userId);
page.querySelector('.lnkCameraUpload').setAttribute('href', 'camerauploadsettings.html?userId=' + userId);
2015-05-27 22:51:48 -07:00
2016-08-22 13:47:16 -07:00
if (appHost.supports('cameraupload')) {
page.querySelector('.lnkCameraUpload').classList.remove('hide');
} else {
page.querySelector('.lnkCameraUpload').classList.add('hide');
}
2015-07-29 19:35:11 -07:00
2016-08-22 13:47:16 -07:00
if (appHost.supports('sync')) {
page.querySelector('.lnkSync').classList.remove('hide');
} else {
page.querySelector('.lnkSync').classList.add('hide');
}
2015-09-24 10:08:10 -07:00
2016-08-22 13:47:16 -07:00
Dashboard.getCurrentUser().then(function (user) {
2015-09-24 22:15:29 -07:00
2016-08-22 13:47:16 -07:00
page.querySelector('.headerUser').innerHTML = user.Name;
2015-09-24 22:15:29 -07:00
2016-08-22 13:47:16 -07:00
if (user.Policy.IsAdministrator) {
page.querySelector('.adminSection').classList.remove('hide');
} else {
page.querySelector('.adminSection').classList.add('hide');
}
});
2015-09-24 22:15:29 -07:00
2016-08-22 13:47:16 -07:00
if (Dashboard.isConnectMode()) {
page.querySelector('.selectServer').classList.remove('hide');
} else {
page.querySelector('.selectServer').classList.add('hide');
}
});
};
2015-05-27 22:51:48 -07:00
});