X-Git-Url: https://git.ktnx.net/?p=icedeb.git;a=blobdiff_plain;f=chrome%2Ficedeb.js;h=3b9eb7bcc1e8ee52f1f4374bc23b7938813fb6ba;hp=66159cff2e222a782dd54c4d57dcdf0bf6799adb;hb=8f5e38a99516512c8cca0855b7b3f68fea0c1aba;hpb=2c8bc47dd316733f9b14462665d909247b2f08b4 diff --git a/chrome/icedeb.js b/chrome/icedeb.js index 66159cf..3b9eb7b 100644 --- a/chrome/icedeb.js +++ b/chrome/icedeb.js @@ -26,10 +26,25 @@ function getClipboardText() { return text; } +function trim_keyword(word) { + if (!word) return word; + + var oldword; + do { + oldword = word; + + word = word.replace(/^\s+/, ''); + word = word.replace(/\s+$/, ''); + word = word.replace(/^#/, ''); + word = word.replace(/[-:\/,]$/, ''); + } while ( oldword != word ); + + return word; +} + function lookup_bts(in_new) { - var bug = getClipboardText(); + var bug = trim_keyword(getClipboardText()); if (!bug) return null; - bug = bug.replace(/^#/, ''); var uri="http://bugs.debian.org/" + bug; if (in_new) { @@ -43,7 +58,7 @@ function lookup_bts(in_new) { } function lookup_pts(in_new) { - var pkg = getClipboardText(); + var pkg = trim_keyword(getClipboardText()); if (!pkg) return null; var uri="http://packages.qa.debian.org/" + pkg; @@ -57,6 +72,21 @@ function lookup_pts(in_new) { } } +function lookup_deb(in_new) { + var pkg = trim_keyword(getClipboardText()); + if (!pkg) return null; + var uri="http://packages.debian.org/" + pkg; + + if (in_new) { + var b = getBrowser(); + var new_tab = b.addTab(uri); + b.selectedTab = new_tab; + } + else { + loadURI(uri); + } +} + Debian = { btsButton: function (e) { if ( e.button == 0 ) @@ -69,6 +99,12 @@ Debian = { lookup_pts(false) else if ( e.button == 1 ) lookup_pts(true); + }, + debButton: function (e) { + if ( e.button == 0 ) + lookup_deb(false) + else if ( e.button == 1 ) + lookup_deb(true); } }