From 3a51ae92a501e9eb8dc1bed4eb1419473aba4604 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sun, 25 Jul 2010 14:44:41 +0200 Subject: Move queryForSelection and affiiliated methods to BZPage. Plus another attempt to make update.rdf work. --- lib/rhbzpage.js | 147 ++++++++++++++++---------------------------------------- 1 file changed, 42 insertions(+), 105 deletions(-) (limited to 'lib/rhbzpage.js') diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index 4458e28..92c6e28 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -228,9 +228,6 @@ RHBugzillaPage.prototype.centralCommandDispatch = function(cmdLabel, cmdParams) case "computeResolution": this.closeSomeRelease(); break; - case "queryStringOurBugzilla": - this.queryForSelection(); - break; case "queryStringUpstreamBugzilla": this.queryUpstream(); break; @@ -437,6 +434,48 @@ RHBugzillaPage.prototype.setBranding = function() { } }; +/** + * Search simple query in the upstream bugzilla appropriate for the component. + */ +RHBugzillaPage.prototype.queryUpstream = function() { + var text = this.getSelectionOrClipboard(); + if (text) { + text = encodeURIComponent(text.trim()); + var queryUpstreamBugsURLArray = this.constantData.queryUpstreamBug; + var urlBase = util.filterByRegexp(queryUpstreamBugsURLArray, this.component); + tabs.open({ + url: urlBase + text, + inBackground: true, + onOpen: function (tab) { + tabs.activeTab = tab; + } + }); + } +}; + +/** + * + */ +RHBugzillaPage.prototype.sendBugUpstream = function() { + var that = this; + var urlStr = util.filterByRegexp(JSON.parse(self.data.load("newUpstreamBug.json")), this + .getOptionValue("component")); + + tabs.open({ + url: urlStr, + inBackground: true, + onOpen: function (tab) { + var otherDoc = tab.contentDocument; + var otherElems = otherDoc.forms.namedItem("Create").elements; + otherElems.namedItem("short_desc").value = that.doc + .getElementById("short_desc_nonedit_display").textContent + .trim(); + otherElems.namedItem("comment").value = that.collectComments(); + tabs.activeTab = tab; + } + }); +}; + RHBugzillaPage.prototype.addCheckXorgLogLink = function addCheckXorgLogLink() { var that = this; if (this.xorglogAnalysis) { @@ -579,108 +618,6 @@ RHBugzillaPage.prototype.fillInChipMagic = function fillInChipMagic() { this.XorgLogAttListIndex++; }; -RHBugzillaPage.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 - * - */ -RHBugzillaPage.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. - */ -RHBugzillaPage.prototype.queryForSelection = function() { - var text = this.getSelectionOrClipboard(); - if (text) { - this.queryInNewTab(text, this.component); - } -}; - -/** - * Search simple query in the upstream bugzilla appropriate for the component. - */ -RHBugzillaPage.prototype.queryUpstream = function() { - var text = this.getSelectionOrClipboard(); - if (text) { - text = encodeURIComponent(text.trim()); - var queryUpstreamBugsURLArray = this.constantData.queryUpstreamBug; - var urlBase = util.filterByRegexp(queryUpstreamBugsURLArray, this.component); - tabs.open({ - url: urlBase + text, - inBackground: true, - onOpen: function (tab) { - tabs.activeTab = tab; - } - }); - } -}; - -/** - * - */ -RHBugzillaPage.prototype.sendBugUpstream = function() { - var that = this; - var urlStr = util.filterByRegexp(JSON.parse(self.data.load("newUpstreamBug.json")), this - .getOptionValue("component")); - - tabs.open({ - url: urlStr, - inBackground: true, - onOpen: function (tab) { - var otherDoc = tab.contentDocument; - var otherElems = otherDoc.forms.namedItem("Create").elements; - otherElems.namedItem("short_desc").value = that.doc - .getElementById("short_desc_nonedit_display").textContent - .trim(); - otherElems.namedItem("comment").value = that.collectComments(); - tabs.activeTab = tab; - } - }); -}; - /** * Parse the row with the attachment * -- cgit