-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserInfo.js
32 lines (29 loc) · 1.26 KB
/
UserInfo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// КЛАСС УПРАВЛЕНИЯ ОТОБРАЖЕНИЕМ ИНФОРМАЦИИ О ПОЛЬЗОВАТЕЛЕ НА СТРАНИЦЕ
export default class UserInfo {
constructor({ profileName, profileJob, profileAvatar }) {
this._userName = document.querySelector(profileName);
this._userDescription = document.querySelector(profileJob);
this._userAvatar = document.querySelector(profileAvatar);
}
// Возвращение объекта с данными пользователя
getUserInfo() {
return {
profileName: this._userName.textContent,
profileJob: this._userDescription.textContent
}
}
// Добавление новых данных пользователя на страницу
setUserInfo(profileName, profileJob) {
// Проверка наличия значений в виде аргументов для корректной работы с сервером (дополнительная подстраховка)
if (profileName && profileJob) {
this._userName.textContent = profileName;
this._userDescription.textContent = profileJob;
}
}
// Обновление аватара
setUserAvatar(profileAvatar) {
if (profileAvatar) {
this._userAvatar.src = profileAvatar;
}
}
}