From 0ace4d34ece35b717b64ee1d3312cdc3c07696b5 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 25 Mar 2011 16:23:51 +0100 Subject: Cut out general bugzilla functions to a special module. --- data/lib/queries.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'data/lib/queries.js') diff --git a/data/lib/queries.js b/data/lib/queries.js index b6e3661..0c00792 100644 --- a/data/lib/queries.js +++ b/data/lib/queries.js @@ -11,7 +11,6 @@ function getSelection () { return text; } - /** * Opens a new tab with a query for the given text in the selected component * @@ -73,3 +72,36 @@ function queryForSelection() { } } } + +/** + * + */ +function queryUpstreamCallback(text, queryUpBug) { + var searchData = filterByRegexp(queryUpBug, getComponent()); + var urlBase = searchData.url; + text = searchData.searchBy+":"+searchData.fillIn+" "+text.trim(); + if (searchData.fillIn == "$$$") { + text = text.replace("$$$", getComponent()); + } + text = encodeURIComponent(text).replace("%20","+"); + postMessage(new Message("OpenURLinTab", urlBase + text)); +} + +/** + * Search simple query in the upstream bugzilla appropriate for the component + * + * @return none + */ +function queryUpstream(qUpBug) { + if (!qUpBug) { + alert("We don't have constantData.queryUpstreamBug set up!"); + return null; + } + var text = getSelection(); + if (!text) { + postMessage(new Message("GetClipboard", "queryUpstream")); + } + else { + queryUpstreamCallback(text, qUpBug); + } +} -- cgit