aboutsummaryrefslogtreecommitdiffstats
path: root/data/lib/queries.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-04-28 13:28:55 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-06-05 14:47:40 +0200
commit55d9a312fbba91f1bcf5e3f3291b7bece8abb178 (patch)
treebb9ef165b425273da47aa000268395f87f26678e /data/lib/queries.js
parent34bbe8e7306a0d0ec014db7512788ed92c625d19 (diff)
downloadbugzilla-triage-55d9a312fbba91f1bcf5e3f3291b7bece8abb178.tar.gz
Reformatting to MoFo coding style
Diffstat (limited to 'data/lib/queries.js')
-rw-r--r--data/lib/queries.js122
1 files changed, 65 insertions, 57 deletions
diff --git a/data/lib/queries.js b/data/lib/queries.js
index 4bf959a..52c6ce6 100644
--- a/data/lib/queries.js
+++ b/data/lib/queries.js
@@ -2,57 +2,61 @@
// http://www.opensource.org/licenses/mit-license.php
"use strict";
-function getSelection () {
- var text = "";
- var selectionObject = window.getSelection();
- if (selectionObject.rangeCount > 0) {
- text = selectionObject.getRangeAt(0).toString().trim();
- }
- return text;
+function getSelection() {
+ var text = "";
+ var selectionObject = window.getSelection();
+ if (selectionObject.rangeCount > 0) {
+ text = selectionObject.getRangeAt(0).toString().trim();
+ }
+ 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
+ *
+ * @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
*
*/
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 (equivComps) {
- var equivCompsArr = equivComps.
- filter(function (REstr) {
- return new RegExp(REstr).test(component);
- }, this);
- if (equivCompsArr.length > 0) {
- component = equivCompsArr[0];
- }
- }
- urlStr += "&component=" + component.trim();
+ var urlStr = "https://" + window.location.hostname
+ + "/buglist.cgi?query_format=advanced";
+ if (product) {
+ urlStr += "&product=" + product.trim();
+ }
+ if (component) {
+ if (equivComps) {
+ var equivCompsArr = equivComps.filter(function(REstr) {
+ return new RegExp(REstr).test(component);
+ }, this);
+ if (equivCompsArr.length > 0) {
+ component = equivCompsArr[0];
+ }
}
+ urlStr += "&component=" + 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 = "&field0-0-0=longdesc&type0-0-0=substring&value0-0-0="
- + text
- + "&field0-0-1=attach_data.thedata&type0-0-1=substring&value0-0-1="
- + text
- + "&field0-0-2=status_whiteboard&type0-0-2=substring&value0-0-2="
- + text;
- urlStr += searchText;
- self.postMessage(new Message("OpenURLinTab", urlStr)); // utils.js is always avaiulable
- }
+ // 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 = "&field0-0-0=longdesc&type0-0-0=substring&value0-0-0="
+ + text
+ + "&field0-0-1=attach_data.thedata&type0-0-1=substring&value0-0-1="
+ + text
+ + "&field0-0-2=status_whiteboard&type0-0-2=substring&value0-0-2="
+ + text;
+ urlStr += searchText;
+ self.postMessage(new Message("OpenURLinTab", urlStr)); // utils.js is
+ // always avaiulable
+ }
}
/**
@@ -60,39 +64,42 @@ function queryInNewTab(text, component, product, equivComps) {
* function this.queryInNewTab, and run it.
*/
function queryForSelection() {
- var text = getSelection();
- if (!text) {
- self.postMessage(new Message("GetClipboard", "queryLocal"));
- } else {
- if (equivalentComponents) {
- queryInNewTab(text, getComponent(), getProduct(), equivalentComponents);
- }
- else {
- queryInNewTab(text, getComponent(), getProduct());
- }
+ var text = getSelection();
+ if (!text) {
+ self.postMessage(new Message("GetClipboard", "queryLocal"));
+ }
+ else {
+ if (equivalentComponents) {
+ queryInNewTab(text, getComponent(), getProduct(),
+ equivalentComponents);
}
+ else {
+ queryInNewTab(text, getComponent(), getProduct());
+ }
+ }
}
/**
- *
+ *
*/
function queryUpstreamCallback(text, queryUpBug) {
var searchData = filterByRegexp(queryUpBug, getComponent());
if (!searchData) {
- return ; // not sure why it should happen, but certainly better
+ return; // not sure why it should happen, but certainly better
}
var urlBase = searchData.url;
- text = searchData.searchBy+":"+searchData.fillIn+" "+text.trim();
+ text = searchData.searchBy + ":" + searchData.fillIn + " "
+ + text.trim();
if (searchData.fillIn == "$$$") {
text = text.replace("$$$", getComponent());
}
- text = encodeURIComponent(text).replace("%20","+");
+ text = encodeURIComponent(text).replace("%20", "+");
self.postMessage(new Message("OpenURLinTab", urlBase + text));
}
/**
* Search simple query in the upstream bugzilla appropriate for the component
- *
+ *
* @return none
*/
function queryUpstream(qUpBug) {
@@ -102,7 +109,8 @@ function queryUpstream(qUpBug) {
}
var text = getSelection();
if (!text) {
- self.postMessage(new Message("GetClipboard", "queryUpstream"));
+ self
+ .postMessage(new Message("GetClipboard", "queryUpstream"));
}
else {
queryUpstreamCallback(text, qUpBug);