aboutsummaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-03-21 00:32:05 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-03-25 14:27:47 +0100
commita90359a5d5ed0f45dfa5da7e154842c08f19d05a (patch)
tree4a4e31b570ebbd50cb1cf2ef28676f610d0e4f49 /data
parent94d80944f20fd1bed0b522613b97762cdb811655 (diff)
downloadbugzilla-triage-a90359a5d5ed0f45dfa5da7e154842c08f19d05a.tar.gz
CLeaned queries.js so that it is independent of external forces.
Diffstat (limited to 'data')
-rw-r--r--data/lib/bzpage.js7
-rw-r--r--data/lib/queries.js17
2 files changed, 16 insertions, 8 deletions
diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js
index d3250ba..87030e4 100644
--- a/data/lib/bzpage.js
+++ b/data/lib/bzpage.js
@@ -16,7 +16,8 @@ var ReporterColor = new Color(255, 255, 166); // RGB 255, 255, 166; HSL 60, 2,
// global variables
var config = {};
var constantData = {}; // This should be probably eliminated ASAP or
- // or done by other means. TODO
+ // or done by other means. TODO
+var equivalentComponents = null;
/**
* central handler processing messages from the main script.
*/
@@ -27,11 +28,13 @@ onMessage = function onMessage(msg) {
document.location.reload(true);
break;
case "queryLocal":
- queryInNewTab(msg.data, getComponent(), getProduct());
+ queryInNewTab(msg.data, getComponent(), getProduct(), equivalentComponents);
break;
case "CreateButtons":
constantData = msg.data.constData;
config = msg.data.config;
+ equivalentComponents = ("equivalentComponents" in constantData) ?
+ constantData.equivalentComponents : null;
generateButtons(msg.data.instPkgs, msg.data.kNodes);
break;
case "Error":
diff --git a/data/lib/queries.js b/data/lib/queries.js
index b43b616..b6e3661 100644
--- a/data/lib/queries.js
+++ b/data/lib/queries.js
@@ -22,16 +22,16 @@ function getSelection () {
* @return None
*
*/
-function queryInNewTab(text, component, product) {
+function queryInNewTab(text, component, product, equivComps) {
var urlStr = "https://" + window.location.hostname + "/buglist.cgi?query_format=advanced";
if (product) {
urlStr += "&product=" + product.trim();
}
if (component) {
- if ("equivalentComponents" in constantData) {
- var equivCompsArr = constantData.equivalentComponents.
+ if (equivComps) {
+ var equivCompsArr = equivComps.
filter(function (REstr) {
- return new RegExp(REstr).test(getComponent());
+ return new RegExp(REstr).test(component);
}, this);
if (equivCompsArr.length > 0) {
component = equivCompsArr[0];
@@ -52,7 +52,7 @@ function queryInNewTab(text, component, product) {
+ "&field0-0-2=status_whiteboard&type0-0-2=substring&value0-0-2="
+ text;
urlStr += searchText;
- postMessage(new Message("OpenURLinTab", urlStr));
+ postMessage(new Message("OpenURLinTab", urlStr)); // utils.js is always avaiulable
}
}
@@ -65,6 +65,11 @@ function queryForSelection() {
if (!text) {
postMessage(new Message("GetClipboard", "queryLocal"));
} else {
- queryInNewTab(text, getComponent(), getProduct());
+ if (equivalentComponents) {
+ queryInNewTab(text, getComponent(), getProduct(), equivalentComponents);
+ }
+ else {
+ queryInNewTab(text, getComponent(), getProduct());
+ }
}
}