mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-01-13 19:50:34 +00:00
42 lines
1.3 KiB
Django/Jinja
42 lines
1.3 KiB
Django/Jinja
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') }}";
|
|
}
|
|
);
|
|
});
|
|
|
|
document.querySelector('#delete-user-button').addEventListener('click', (event) => {
|
|
Requests.users.entity.delete(currentUserId)
|
|
.then((response) => {window.location.href = '/';});
|
|
});
|