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