X-Git-Url: https://git.ktnx.net/?p=icedeb.git;a=blobdiff_plain;f=chrome%2Fbutton.js;h=823c2afdb6f48973b1cadbe4dd576d17a49216e9;hp=f1ec859ba2eb4e040d86e21fd4be11e39f8ef18a;hb=e754f90aea675f92a80513034e2b014a923119d4;hpb=0e07f53e79d4d4f21e86d5b3a98816d88e155ff0 diff --git a/chrome/button.js b/chrome/button.js index f1ec859..823c2af 100644 --- a/chrome/button.js +++ b/chrome/button.js @@ -1,8 +1,53 @@ -CustomButton = { +function getClipboardText() { + var clip = Components.classes['@mozilla.org/widget/clipboard;1'] + .getService(Components.interfaces.nsIClipboard); + if (!clip) return null; -1: function () { - alert("Just testing") - }, + var trans = Components.classes['@mozilla.org/widget/transferable;1'] + .createInstance(Components.interfaces.nsITransferable); + if (!trans) return null; + trans.addDataFlavor("text/unicode"); + clip.getData(trans, + clip.supportsSelectionClipboard() + ? clip.kSelectionClipboard + : clip.kGlobalClipboard + ); + + var str = new Object; + var strLength = new Object; + trans.getTransferData("text/unicode", str, strLength); + + var text = null; + + if (str) str = str.value.QueryInterface(Components.interfaces.nsISupportsString); + if (str) text = str.data.substring(0, strLength.value / 2); + + return text; +} + +function lookup_bts(in_new) { + var bug = getClipboardText(); + if (!bug) return null; + bug = bug.replace(/^#/, ''); + var uri="http://bugs.debian.org/" + bug; + + 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 ) + lookup_bts(false) + else if ( e.button == 1 ) + lookup_bts(true); + } }