2 getClipboardText: function() {
3 var clip = Components.classes['@mozilla.org/widget/clipboard;1']
4 .getService(Components.interfaces.nsIClipboard);
5 if (!clip) return null;
7 var trans = Components.classes['@mozilla.org/widget/transferable;1']
8 .createInstance(Components.interfaces.nsITransferable);
9 if (!trans) return null;
11 trans.addDataFlavor("text/unicode");
13 clip.supportsSelectionClipboard()
14 ? clip.kSelectionClipboard
15 : clip.kGlobalClipboard
21 trans.getTransferData("text/unicode", s, len);
27 p = s.value.QueryInterface(Components.interfaces.nsISupportsString, res);
29 text = p.data.substring(0, len.value / 2);
33 trim_keyword: function(word) {
34 if (!word) return word;
40 word = word.replace(/^[^a-zA-Z0-9]+/, '');
41 word = word.replace(/[^a-zA-Z0-9]+$/, '');
42 } while ( oldword != word );
46 lookup_bts: function(in_new) {
47 var bug = IceDeb.trim_keyword(IceDeb.getClipboardText());
48 if (!bug) return null;
49 var uri="http://bugs.debian.org/" + bug;
53 var new_tab = b.addTab(uri);
54 b.selectedTab = new_tab;
60 lookup_pts: function(in_new) {
61 var pkg = IceDeb.trim_keyword(IceDeb.getClipboardText());
62 if (!pkg) return null;
63 var uri="http://packages.qa.debian.org/" + pkg;
67 var new_tab = b.addTab(uri);
68 b.selectedTab = new_tab;
74 lookup_deb: function(in_new) {
75 var pkg = IceDeb.trim_keyword(IceDeb.getClipboardText());
76 if (!pkg) return null;
77 var uri="http://packages.debian.org/" + pkg;
81 var new_tab = b.addTab(uri);
82 b.selectedTab = new_tab;
88 lookup_ml: function(in_new) {
89 var msg_id = IceDeb.trim_keyword(IceDeb.getClipboardText());
90 if (!msg_id) msg_id = '';
91 var uri="http://lists.debian.org/msgid-search/" + msg_id;
95 var new_tab = b.addTab(uri);
96 b.selectedTab = new_tab;
103 btsButton: function (e) {
105 IceDeb.lookup_bts(false)
106 else if ( e.button == 1 )
107 IceDeb.lookup_bts(true);
109 ptsButton: function (e) {
111 IceDeb.lookup_pts(false)
112 else if ( e.button == 1 )
113 IceDeb.lookup_pts(true);
115 debButton: function (e) {
117 IceDeb.lookup_deb(false)
118 else if ( e.button == 1 )
119 IceDeb.lookup_deb(true);
121 mlButton: function (e) {
123 IceDeb.lookup_ml(false)
124 else if ( e.button == 1 )
125 IceDeb.lookup_ml(true);