X-Git-Url: https://git.ktnx.net/?p=icedeb.git;a=blobdiff_plain;f=icedeb.js;h=41117778fa9a08fc08acb30ff44b05acb69b465b;hp=5b8cd3c26dd934118893185c1cf07a819ba3cd04;hb=c28c4dad3eb96d8ad3a01ea68aa1c29c4fbddce9;hpb=5b2e737b05ecb717184cd5e2c65db4285aeb42da diff --git a/icedeb.js b/icedeb.js index 5b8cd3c..4111777 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,6 +147,8 @@ 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': @@ -171,13 +174,16 @@ function link_clicked(e) { function check_likely_inputs(q) { let cnt = document.getElementById('button-list-container').classList; - cnt.remove('like-b', 'like-p', 'like-m', 'like-i'); + cnt.remove('like-b', 'like-p', 'like-m', 'like-i', 'like-s'); document.querySelectorAll('.likely') .forEach((el) => { el.classList.remove('likely'); }); - if ( /^\d+$/.test(q) || /^CVE-/.test(q) ) + q = q.replace(/^\s+/, ''); + q = q.replace(/\s+$/, ''); + + if ( /^#?\d+$/.test(q) || /^CVE-/.test(q) ) cnt.add('like-b'); if ( /^[a-z0-9][a-z0-9\-+.]+$/.test(q) ) @@ -189,23 +195,38 @@ function check_likely_inputs(q) { 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') + if ( /^d[sl]a[- ]\d+(-\d+)?$/i.test(q) ) + cnt.add('like-s'); + + document.querySelectorAll('.like-b .hint.b, .like-p .hint.p, .like-m .hint.m, .like-i .hint.i, .like-s .hint.s') .forEach((el) => { el.parentElement.parentElement.classList.add('likely'); } ); } -function get_clipboard_contents() { - let clip_pot = document.getElementById('clip-pot'); +function react_to_clipboard_text(text) { let clip_input = document.getElementById("clipboard"); - clip_pot.focus(); - if (document.execCommand("Paste")) { - let q = clip_pot.textContent.trim(); - clip_input.value = q; - clip_input.focus(); - clip_input.setSelectionRange(0, clip_input.value.length); - - check_likely_inputs(q); + clip_input.value = text; + clip_input.focus(); + clip_input.setSelectionRange(0, clip_input.value.length); + + check_likely_inputs(text); +} + +function get_clipboard_contents() { + if (navigator.clipboard && navigator.clipboard.readText) { + navigator.clipboard.readText().then(function(q){ + react_to_clipboard_text(q); + }); + } + else { + let clip_pot = document.getElementById('clip-pot'); + let clip_input = document.getElementById("clipboard"); + clip_pot.focus(); + if (document.execCommand("Paste")) { + let q = clip_pot.textContent.trim(); + react_to_clipboard_text(q); + } } } @@ -231,3 +252,5 @@ window.addEventListener('DOMContentLoaded', (e) => { window.requestAnimationFrame(get_clipboard_contents); }); }); + +// vim: sw=2