From c09557d824aa7a412a952984dd24ed1489f25782 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Fri, 16 Feb 2024 13:05:57 +0000 Subject: [PATCH 1/2] Remove jQuery from SSH key form parser - Switched to plain JavaScript - Tested the SSH key title functionality and it works as before Signed-off-by: Yarden Shoham --- web_src/js/features/sshkey-helper.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/web_src/js/features/sshkey-helper.js b/web_src/js/features/sshkey-helper.js index 099b54d3a648c..fac15db0c9f5c 100644 --- a/web_src/js/features/sshkey-helper.js +++ b/web_src/js/features/sshkey-helper.js @@ -1,12 +1,10 @@ -import $ from 'jquery'; - export function initSshKeyFormParser() { -// Parse SSH Key - $('#ssh-key-content').on('change paste keyup', function () { - const arrays = $(this).val().split(' '); - const $title = $('#ssh-key-title'); - if ($title.val() === '' && arrays.length === 3 && arrays[2] !== '') { - $title.val(arrays[2]); + // Parse SSH Key + document.getElementById('ssh-key-content')?.addEventListener('input', function () { + const arrays = this.value.split(' '); + const title = document.getElementById('ssh-key-title'); + if (title.value === '' && arrays.length === 3 && arrays[2] !== '') { + title.value = arrays[2]; } }); } From eb8e15ef3edb3de0a48c0ded5b06066d86b010cf Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Fri, 16 Feb 2024 15:21:18 +0200 Subject: [PATCH 2/2] Update web_src/js/features/sshkey-helper.js Co-authored-by: silverwind --- web_src/js/features/sshkey-helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/features/sshkey-helper.js b/web_src/js/features/sshkey-helper.js index fac15db0c9f5c..3960eefe8e54f 100644 --- a/web_src/js/features/sshkey-helper.js +++ b/web_src/js/features/sshkey-helper.js @@ -3,7 +3,7 @@ export function initSshKeyFormParser() { document.getElementById('ssh-key-content')?.addEventListener('input', function () { const arrays = this.value.split(' '); const title = document.getElementById('ssh-key-title'); - if (title.value === '' && arrays.length === 3 && arrays[2] !== '') { + if (!title.value && arrays.length === 3 && arrays[2] !== '') { title.value = arrays[2]; } });