aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bzpage.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-07-25 14:44:41 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-07-25 14:44:41 +0200
commit3a51ae92a501e9eb8dc1bed4eb1419473aba4604 (patch)
tree4ee3b33d3413d733622858816c765384b5662c61 /lib/bzpage.js
parentd428a8122cbc803ef99acd6db03323ceb5b76f53 (diff)
downloadbugzilla-triage-3a51ae92a501e9eb8dc1bed4eb1419473aba4604.tar.gz
Move queryForSelection and affiiliated methods to BZPage.
Plus another attempt to make update.rdf work.
Diffstat (limited to 'lib/bzpage.js')
-rw-r--r--lib/bzpage.js65
1 files changed, 64 insertions, 1 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js
index 084b924..e315922 100644
--- a/lib/bzpage.js
+++ b/lib/bzpage.js
@@ -249,6 +249,9 @@ BZPage.prototype.centralCommandDispatch = function centralCommandDispatch (cmdLa
case "addCC":
this.addToCCList(cmdParams);
break;
+ case "queryStringOurBugzilla":
+ this.queryForSelection();
+ break;
// TODO flags, see also
case "commit":
@@ -488,7 +491,7 @@ BZPage.prototype.setConfigurationButton = function setConfigurationButton () {
BZPage.prototype.parseMailto = function parseMailto(aElement) {
if (aElement) {
var email = decodeURI(aElement.getAttribute("href")).
- split(":")[1];
+ split(":")[1];
}
return null;
};
@@ -839,6 +842,66 @@ BZPage.prototype.setUpLogging = function setUpLogging () {
}
};
+BZPage.prototype.getSelectionOrClipboard = function getSelectionOrClipboard () {
+ var text = selection.text;
+ if (!text) {
+ text = clip.get();
+ }
+ return text;
+};
+
+/**
+ * Opens a new tab with a query for the given text in the selected component
+ *
+ * @param text to be searched for
+ * @param component String with the component name (maybe latter regexp?)
+ * @param product (optional) string with the product name, if undefined,
+ * search in all products
+ * @return None
+ *
+ */
+BZPage.prototype.queryInNewTab = function(text, component, product) {
+ var urlStr = "https://bugzilla.redhat.com/buglist.cgi?query_format=advanced";
+ if (product) {
+ urlStr += "&product=" + product.trim();
+ }
+ if (component) {
+ urlStr += "&field0-0-0=component&type0-0-0=substring&value0-0-0="
+ + component.trim();
+ }
+ // using more complicated query tables here, because they can be more easily
+ // edited
+ // for further investigative searches
+ if (text) {
+ text = encodeURIComponent(text.trim());
+ var searchText = "&field1-0-0=longdesc&type1-0-0=substring&value1-0-0="
+ + text
+ + "&field1-0-1=attach_data.thedata&type1-0-1=substring&value1-0-1="
+ + text
+ + "&field1-0-2=status_whiteboard&type1-0-2=substring&value1-0-2="
+ + text;
+ urlStr += searchText;
+ tabs.open({
+ url: urlStr,
+ inBackground: true,
+ onOpen: function (t) {
+ tabs.activeTab = t;
+ }
+ });
+ }
+};
+
+/**
+ * Get the text to search for and prepare other things for the real executive
+ * function this.queryInNewTab, and run it.
+ */
+BZPage.prototype.queryForSelection = function() {
+ var text = this.getSelectionOrClipboard();
+ if (text) {
+ this.queryInNewTab(text, this.component);
+ }
+};
+
/**
* adds a person to the CC list, if it isn't already there
*