aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features/user-settings.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js/features/user-settings.ts')
-rw-r--r--web_src/js/features/user-settings.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/web_src/js/features/user-settings.ts b/web_src/js/features/user-settings.ts
new file mode 100644
index 0000000000..41939c0f52
--- /dev/null
+++ b/web_src/js/features/user-settings.ts
@@ -0,0 +1,19 @@
+import {hideElem, showElem} from '../utils/dom.ts';
+
+export function initUserSettings() {
+ if (!document.querySelectorAll('.user.settings.profile').length) return;
+
+ const usernameInput = document.querySelector('#username');
+ if (!usernameInput) return;
+ usernameInput.addEventListener('input', function () {
+ const prompt = document.querySelector('#name-change-prompt');
+ const promptRedirect = document.querySelector('#name-change-redirect-prompt');
+ if (this.value.toLowerCase() !== this.getAttribute('data-name').toLowerCase()) {
+ showElem(prompt);
+ showElem(promptRedirect);
+ } else {
+ hideElem(prompt);
+ hideElem(promptRedirect);
+ }
+ });
+}