Skip to content

Commit 84a8a3c

Browse files
committed
Remove jQuery from username change prompt
- Switched to plain JavaScript - Tested the user rename prompt toggling functionality and it works as before - Fixed bug that allowed pasting with the mouse to avoid the prompt Signed-off-by: Yarden Shoham <[email protected]>
1 parent b7dcec6 commit 84a8a3c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

web_src/js/features/user-settings.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import $ from 'jquery';
21
import {hideElem, showElem} from '../utils/dom.js';
32

43
export function initUserSettings() {
5-
if ($('.user.settings.profile').length > 0) {
6-
$('#username').on('keyup', function () {
7-
const $prompt = $('#name-change-prompt');
8-
const $prompt_redirect = $('#name-change-redirect-prompt');
9-
if ($(this).val().toString().toLowerCase() !== $(this).data('name').toString().toLowerCase()) {
10-
showElem($prompt);
11-
showElem($prompt_redirect);
4+
if (document.querySelectorAll('.user.settings.profile').length === 0) return;
5+
6+
const usernameInput = document.getElementById('username');
7+
if (usernameInput) {
8+
usernameInput.addEventListener('input', function () {
9+
const prompt = document.getElementById('name-change-prompt');
10+
const promptRedirect = document.getElementById('name-change-redirect-prompt');
11+
if (this.value.toLowerCase() !== this.dataset.name.toLowerCase()) {
12+
showElem(prompt);
13+
showElem(promptRedirect);
1214
} else {
13-
hideElem($prompt);
14-
hideElem($prompt_redirect);
15+
hideElem(prompt);
16+
hideElem(promptRedirect);
1517
}
1618
});
1719
}

0 commit comments

Comments
 (0)