]> git.ktnx.net Git - icedeb.git/blob - chrome/button.js
clicking on the toolbar button now loads BTS bug page
[icedeb.git] / chrome / button.js
1 function getClipboardText() {
2     var clip = Components.classes['@mozilla.org/widget/clipboard;1']
3         .getService(Components.interfaces.nsIClipboard);
4     if (!clip) return null;
5
6     var trans = Components.classes['@mozilla.org/widget/transferable;1']
7         .createInstance(Components.interfaces.nsITransferable);
8     if (!trans) return null;
9
10     trans.addDataFlavor("text/unicode");
11     clip.getData(trans,
12             clip.supportsSelectionClipboard()
13             ? clip.kSelectionClipboard
14             : clip.kGlobalClipboard
15     );
16
17     var str = new Object;
18     var strLength = new Object;
19     trans.getTransferData("text/unicode", str, strLength);
20
21     var text = null;
22
23     if (str) str  = str.value.QueryInterface(Components.interfaces.nsISupportsString);
24     if (str) text = str.data.substring(0, strLength.value / 2);
25
26     return text;
27 }
28
29 function lookup_bts() {
30     var bug = getClipboardText();
31     loadURI("http://bugs.debian.org/" + bug);
32 }
33
34 Debian = {
35     btsButton: function (e) {
36         lookup_bts();
37     }
38 }
39