2024-07-07 23:32:30 +08:00
|
|
|
import {hideElem, showElem} from '../utils/dom.ts';
|
2024-11-28 10:15:59 +08:00
|
|
|
import {initCompCropper} from './comp/Cropper.ts';
|
|
|
|
|
|
|
|
function initUserSettingsAvatarCropper() {
|
|
|
|
const fileInput = document.querySelector<HTMLInputElement>('#new-avatar');
|
|
|
|
const container = document.querySelector<HTMLElement>('.user.settings.profile .cropper-panel');
|
|
|
|
const imageSource = container.querySelector<HTMLImageElement>('.cropper-source');
|
|
|
|
initCompCropper({container, fileInput, imageSource});
|
|
|
|
}
|
2022-01-29 05:00:11 +08:00
|
|
|
|
2021-10-17 01:28:04 +08:00
|
|
|
export function initUserSettings() {
|
2024-11-28 10:15:59 +08:00
|
|
|
if (!document.querySelector('.user.settings.profile')) return;
|
|
|
|
|
|
|
|
initUserSettingsAvatarCropper();
|
2024-02-16 23:52:50 +08:00
|
|
|
|
2024-06-11 04:49:33 +08:00
|
|
|
const usernameInput = document.querySelector('#username');
|
2024-02-16 23:52:50 +08:00
|
|
|
if (!usernameInput) return;
|
|
|
|
usernameInput.addEventListener('input', function () {
|
2024-06-11 04:49:33 +08:00
|
|
|
const prompt = document.querySelector('#name-change-prompt');
|
|
|
|
const promptRedirect = document.querySelector('#name-change-redirect-prompt');
|
2024-02-16 23:52:50 +08:00
|
|
|
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
|
|
|
}
|