From: Damyan Ivanov Date: Thu, 26 Feb 2009 12:35:26 +0000 (+0200) Subject: clicking on the toolbar button now loads BTS bug page X-Git-Tag: 0.2~4 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=8d9f234a2cc9eb90f3cfae0e525a733cff252437;p=icedeb.git clicking on the toolbar button now loads BTS bug page --- diff --git a/chrome/button.js b/chrome/button.js index a948399..3dadd3e 100644 --- a/chrome/button.js +++ b/chrome/button.js @@ -1,8 +1,39 @@ -Debian = { +function getClipboardText() { + var clip = Components.classes['@mozilla.org/widget/clipboard;1'] + .getService(Components.interfaces.nsIClipboard); + if (!clip) return null; + + 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; -btsButton: function (e) { - alert("Just testing") - }, + if (str) str = str.value.QueryInterface(Components.interfaces.nsISupportsString); + if (str) text = str.data.substring(0, strLength.value / 2); + return text; +} + +function lookup_bts() { + var bug = getClipboardText(); + loadURI("http://bugs.debian.org/" + bug); +} + +Debian = { + btsButton: function (e) { + lookup_bts(); + } }