2023-02-19 05:06:14 +01:00
|
|
|
import {hideElem, showElem} from '../utils/dom.js';
|
2022-01-28 22:00:11 +01:00
|
|
|
|
2021-10-16 19:28:04 +02:00
|
|
|
export function initUserSettings() {
|
2024-03-25 19:37:55 +01:00
|
|
|
if (!document.querySelectorAll('.user.settings.profile').length) return;
|
2024-02-16 16:52:50 +01:00
|
|
|
|
2024-06-10 22:49:33 +02:00
|
|
|
const usernameInput = document.querySelector('#username');
|
2024-02-16 16:52:50 +01:00
|
|
|
if (!usernameInput) return;
|
|
|
|
usernameInput.addEventListener('input', function () {
|
2024-06-10 22:49:33 +02:00
|
|
|
const prompt = document.querySelector('#name-change-prompt');
|
|
|
|
const promptRedirect = document.querySelector('#name-change-redirect-prompt');
|
2024-02-16 16:52:50 +01:00
|
|
|
if (this.value.toLowerCase() !== this.getAttribute('data-name').toLowerCase()) {
|
|
|
|
showElem(prompt);
|
|
|
|
showElem(promptRedirect);
|
|
|
|
} else {
|
|
|
|
hideElem(prompt);
|
|
|
|
hideElem(promptRedirect);
|
|
|
|
}
|
|
|
|
});
|
2021-10-16 19:28:04 +02:00
|
|
|
}
|