X-Git-Url: https://git.ktnx.net/?p=icedeb.git;a=blobdiff_plain;f=icedeb.js;h=b9e8460c89ce92cf118f867a4d57abe03f75a3ec;hp=2d2a10e24d61824a54f91d3a1afec5df45b90695;hb=b6baa5ee6065621b7cd148b563145a4cc57fe73f;hpb=2838502fb3e43401e873dd853cc9338e80c6d02a diff --git a/icedeb.js b/icedeb.js index 2d2a10e..b9e8460 100644 --- a/icedeb.js +++ b/icedeb.js @@ -30,6 +30,7 @@ function trim(word) { word = word.replace(/^[^a-zA-Z0-9]+/, ''); word = word.replace(/[^a-zA-Z0-9]+$/, ''); word = word.replace(/^Bug#/i, ''); + word = word.replace(/^#/, ''); } while ( oldword != word ); return word; @@ -146,8 +147,16 @@ function link_clicked(e) { url = 'https://buildd.debian.org/' + clip; break; case 'security': + clip = clip.replace(' ', '-'); + clip = clip.toUpperCase(); url = 'https://security-tracker.debian.org/tracker/' + clip; break; + case 'piuparts': + url = `https://piuparts.debian.org/sid/source/${clip.substring(0,1)}/${clip}.html`; + break; + case 'r-b': + url = 'https://tests.reproducible-builds.org/debian/rb-pkg/' + clip + '.html'; + break; } open_link(url, e.button == 1) @@ -162,14 +171,44 @@ function link_clicked(e) { return false; } +function check_likely_inputs(q) { + let cnt = document.getElementById('button-list-container').classList; + + cnt.remove('like-b', 'like-p', 'like-m', 'like-i'); + document.querySelectorAll('.likely') + .forEach((el) => { + el.classList.remove('likely'); + }); + + if ( /^#?\d+$/.test(q) || /^CVE-/.test(q) ) + cnt.add('like-b'); + + if ( /^[a-z0-9][a-z0-9\-+.]+$/.test(q) ) + cnt.add('like-p'); + + if ( /.@[a-z0-9-]/i.test(q) ) + cnt.add('like-m'); + + if ( /^<.+@.+>$/.test(q) ) + cnt.add('like-i'); + + document.querySelectorAll('.like-b .hint.b, .like-p .hint.p, .like-m .hint.m, .like-i .hint.i') + .forEach((el) => { + el.parentElement.parentElement.classList.add('likely'); + } ); +} + function get_clipboard_contents() { let clip_pot = document.getElementById('clip-pot'); let clip_input = document.getElementById("clipboard"); clip_pot.focus(); if (document.execCommand("Paste")) { - clip_input.value = clip_pot.textContent.trim(); + let q = clip_pot.textContent.trim(); + clip_input.value = q; clip_input.focus(); - clip_input.setSelectionRange(0, clip_input.value.length) + clip_input.setSelectionRange(0, clip_input.value.length); + + check_likely_inputs(q); } } @@ -179,6 +218,11 @@ window.addEventListener('DOMContentLoaded', (e) => { el.addEventListener('mouseup', link_clicked); }); + document.querySelector('#clipboard') + .addEventListener('input', function(ev) { + check_likely_inputs(ev.target.value); + }); + document.addEventListener('change', (e) => { if ( !e.target.classList.contains('icedeb-option') ) return;