Skip to content

Commit

Permalink
Remove jQuery from SSH key form parser (go-gitea#29193)
Browse files Browse the repository at this point in the history
- Switched to plain JavaScript
- Tested the SSH key title functionality and it works as before

# Demo using JavaScript without jQuery

![action](https://github.com/go-gitea/gitea/assets/20454870/4785c13d-8d30-448e-b74a-263935e2769f)

---------

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
Co-authored-by: silverwind <me@silverwind.io>
  • Loading branch information
yardenshoham and silverwind committed Feb 20, 2024
1 parent a8fb47e commit 570fc32
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions web_src/js/features/sshkey-helper.js
Original file line number Diff line number Diff line change
@@ -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];
}
});
}

0 comments on commit 570fc32

Please sign in to comment.