From 993d74ee232155ee7deb5ca452b43223e16a3a3d Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Thu, 2 Mar 2023 18:41:46 +0800 Subject: [PATCH] remove jq and fix value check --- web_src/js/features/tag-name-editor.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/web_src/js/features/tag-name-editor.js b/web_src/js/features/tag-name-editor.js index 6a3ddc63f1b94..9b0a2cbd9f9a6 100644 --- a/web_src/js/features/tag-name-editor.js +++ b/web_src/js/features/tag-name-editor.js @@ -1,4 +1,3 @@ -import $ from 'jquery'; import {hideElem, showElem} from '../utils/dom.js'; export function initTagNameEditor() { @@ -12,18 +11,18 @@ export function initTagNameEditor() { const newTagHelperText = el.getAttribute('data-tag-helper-new'); const existingTagHelperText = el.getAttribute('data-tag-helper-existing'); - $('#tag-name').on('keyup', (e) => { + document.getElementById('tag-name').addEventListener('keyup', (e) => { const value = e.target.value; if (existingTags.includes(value)) { // If the tag already exists, hide the target branch selector. - hideElem($('#tag-target-selector')); - $('#tag-helper').text(existingTagHelperText); + hideElem('#tag-target-selector'); + document.getElementById('tag-helper').innerText = existingTagHelperText; } else { - showElem($('#tag-target-selector')); - if (typeof value === 'string' && value.length > 0) { - $('#tag-helper').text(newTagHelperText); + showElem('#tag-target-selector'); + if (value) { + document.getElementById('tag-helper').innerText = newTagHelperText; } else { - $('#tag-helper').text(defaultTagHelperText); + document.getElementById('tag-helper').innerText = defaultTagHelperText; } } });