2023-02-19 09:36:14 +05:30
|
|
|
import {hideElem, showElem} from '../utils/dom.js';
|
2022-01-29 02:30:11 +05:30
|
|
|
|
2023-09-26 11:26:20 +05:30
|
|
|
function onPronounsDropdownUpdate() {
|
|
|
|
const pronounsCustom = document.getElementById('pronouns-custom');
|
2023-09-26 11:51:52 +05:30
|
|
|
const pronounsDropdown = document.getElementById('pronouns-dropdown');
|
|
|
|
const pronounsInput = pronounsDropdown.querySelector('input');
|
2023-09-26 11:26:20 +05:30
|
|
|
const isCustom = !(
|
2023-09-26 11:51:52 +05:30
|
|
|
pronounsInput.value === '' ||
|
2023-09-26 11:26:20 +05:30
|
|
|
pronounsInput.value === 'he/him' ||
|
|
|
|
pronounsInput.value === 'she/her' ||
|
|
|
|
pronounsInput.value === 'they/them' ||
|
2023-09-26 23:24:18 +05:30
|
|
|
pronounsInput.value === 'it/its' ||
|
2024-02-24 23:54:12 +05:30
|
|
|
pronounsInput.value === 'any pronouns'
|
2023-09-26 11:26:20 +05:30
|
|
|
);
|
|
|
|
if (isCustom) {
|
2023-09-26 11:51:52 +05:30
|
|
|
if (pronounsInput.value === '!') {
|
|
|
|
pronounsCustom.value = '';
|
|
|
|
} else {
|
|
|
|
pronounsCustom.value = pronounsInput.value;
|
|
|
|
}
|
2023-09-26 11:26:20 +05:30
|
|
|
pronounsCustom.style.display = '';
|
|
|
|
} else {
|
|
|
|
pronounsCustom.style.display = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function onPronounsCustomUpdate() {
|
|
|
|
const pronounsCustom = document.getElementById('pronouns-custom');
|
|
|
|
const pronounsInput = document.querySelector('#pronouns-dropdown input');
|
|
|
|
pronounsInput.value = pronounsCustom.value;
|
|
|
|
}
|
|
|
|
|
2021-10-16 22:58:04 +05:30
|
|
|
export function initUserSettings() {
|
2024-03-26 00:07:55 +05:30
|
|
|
if (!document.querySelectorAll('.user.settings.profile').length) return;
|
2024-02-16 21:22:50 +05:30
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
2023-09-26 11:26:20 +05:30
|
|
|
|
|
|
|
const pronounsDropdown = document.getElementById('pronouns-dropdown');
|
|
|
|
const pronounsCustom = document.getElementById('pronouns-custom');
|
|
|
|
const pronounsInput = pronounsDropdown.querySelector('input');
|
|
|
|
pronounsCustom.removeAttribute('name');
|
|
|
|
pronounsDropdown.style.display = '';
|
|
|
|
onPronounsDropdownUpdate();
|
|
|
|
pronounsInput.addEventListener('change', onPronounsDropdownUpdate);
|
|
|
|
pronounsCustom.addEventListener('input', onPronounsCustomUpdate);
|
2021-10-16 22:58:04 +05:30
|
|
|
}
|