mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-01-14 20:20:33 +00:00
37 lines
1.1 KiB
Plaintext
37 lines
1.1 KiB
Plaintext
|
let publicProfile = document.querySelector('#public-profile');
|
||
|
let disableButtons = document.querySelectorAll('[data-action="disable"]');
|
||
|
let deleteButton = document.querySelector('#delete-avatar');
|
||
|
let avatar = document.querySelector('#avatar');
|
||
|
let avatarUpload = document.querySelector('#avatar-upload');
|
||
|
|
||
|
for (let disableButton of disableButtons) {
|
||
|
disableButton.disabled = !publicProfile.checked;
|
||
|
}
|
||
|
|
||
|
publicProfile.addEventListener('change', () => {
|
||
|
if (publicProfile.checked) {
|
||
|
for (let disableButton of disableButtons) {
|
||
|
disableButton.disabled = false;
|
||
|
}
|
||
|
} else {
|
||
|
for (let disableButton of disableButtons) {
|
||
|
disableButton.checked = false;
|
||
|
disableButton.disabled = true;
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
avatarUpload.addEventListener('change', function() {
|
||
|
let file = this.files[0];
|
||
|
avatar.src = URL.createObjectURL(file);
|
||
|
});
|
||
|
|
||
|
deleteButton.addEventListener('click', () => {
|
||
|
Requests.users.entity.deleteAvatar({{ user.hashid|tojson }})
|
||
|
.then(
|
||
|
(response) => {
|
||
|
avatar.src = "{{ url_for('static', filename='images/user_avatar.png') }}";
|
||
|
}
|
||
|
);
|
||
|
});
|