aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rhbzpage.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-06-19 22:08:04 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-06-19 22:08:04 +0200
commit87b9c2d6d0a1bda477f15af227d758c5fc3e55e0 (patch)
tree1781a0d60ae99c783add1205722d49da3d2d4143 /lib/rhbzpage.js
parent76e764fb8e4f9d52dc92e97c6408c169142b104f (diff)
downloadbugzilla-triage-87b9c2d6d0a1bda477f15af227d758c5fc3e55e0.tar.gz
Loads a bug page without crash!!!
There is not jetpack. call in used modules.
Diffstat (limited to 'lib/rhbzpage.js')
-rw-r--r--lib/rhbzpage.js106
1 files changed, 46 insertions, 60 deletions
diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js
index 5e27b4b..123f87e 100644
--- a/lib/rhbzpage.js
+++ b/lib/rhbzpage.js
@@ -1,5 +1,4 @@
/*jslint onevar: false, browser: true, evil: true, laxbreak: true, undef: true, nomen: true, eqeqeq: true, bitwise: true, maxerr: 1000, immed: false, white: false, plusplus: false, regexp: false, undef: false */
-/*global jetpack */
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
"use strict";
@@ -11,6 +10,8 @@ var clip = require("clipboard");
var Color = require("color").Color;
var BZPage = require("bzpage").BZPage;
var url = require("url");
+var selection = require("selection");
+var tabs = require("tabs");
// var TriagedDistro = 13;
// var NumberOfFrames = 7;
// var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi";
@@ -65,20 +66,6 @@ var RHBugzillaPage = function RHBugzillaPage(doc, config) {
var ITbutton = this.doc.getElementById("cf_issuetracker");
this.its = ITbutton ? ITbutton.value.trim() : "";
- // Prepare for query buttons
- // FIXME getting null for commentArea sometimes
- var commentArea = this.doc.getElementById("comment_status_commit");
- if (commentArea) {
- var brElementPlacer = commentArea.getElementsByTagName("br");
- console.log("brElementPlacer.length = " + brElementPlacer.length);
- brElementPlacer = brElementPlacer[0];
- if (brElementPlacer) {
- brElementPlacer.setAttribute("id","brElementPlacer_location");
- brElementPlacer.parentNode.insertBefore(this.doc.createElement("br"),
- brElementPlacer);
- }
- }
-
// set default assignee on change of the component
this.doc.getElementById("component").addEventListener("change",
function() {
@@ -177,8 +164,8 @@ RHBugzillaPage.prototype.closeSomeRelease = function() {
var text = "";
var resolution = "";
- if (jetpack.selection.text) {
- text = jetpack.select.text.trim();
+ if (selection.text) {
+ text = selection.text.trim();
}
if (text.length > 0) {
resolution = "CURRENTRELEASE";
@@ -406,9 +393,8 @@ RHBugzillaPage.prototype.setBranding = function() {
// mark suspicious components
var compElems;
- var suspiciousComponents = config.gJSONData.configData.suspiciousComponents;
- if (suspiciousComponents
- && util.isInList(this.component, suspiciousComponents)
+ if (this.suspiciousComponents
+ && util.isInList(this.component, this.suspiciousComponents)
&& (compElems = this.doc
.getElementById("bz_component_edit_container"))) {
compElems.style.background = "red none";
@@ -546,6 +532,17 @@ RHBugzillaPage.prototype.fillInChipMagic = function () {
this.XorgLogAttListIndex++;
};
+RHBugzillaPage.prototype.getSelectionOrClipboard = function getSelectionOrClipboard () {
+ var text = selection.text;
+ console.log("selection = " + text);
+ if (!text) {
+ text = clip.get();
+ console.log("clipboard = " + text);
+ }
+ console.log("text = " + text);
+ return text;
+};
+
/**
* Opens a new tab with a query for the given text in the selected component
*
@@ -560,12 +557,12 @@ RHBugzillaPage.prototype.queryInNewTab = function(text, component, product) {
console.log("queryInNewTab / text = " + text);
console.log("queryInNewTab / component = " + component);
console.log("queryInNewTab / product = " + product);
- var url = "https://bugzilla.redhat.com/buglist.cgi?query_format=advanced";
+ var urlStr = "https://bugzilla.redhat.com/buglist.cgi?query_format=advanced";
if (product) {
- url += "&product=" + product.trim();
+ urlStr += "&product=" + product.trim();
}
if (component) {
- url += "&field0-0-0=component&type0-0-0=substring&value0-0-0="
+ 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
@@ -579,18 +576,8 @@ RHBugzillaPage.prototype.queryInNewTab = function(text, component, product) {
+ text
+ "&field1-0-2=status_whiteboard&type1-0-2=substring&value1-0-2="
+ text;
- url += searchText;
- jetpack.tabs.open(url);
- // Don't do it ... b.m.o is apparently not powerful enough to sustain
- // the weight
- // of the search
- if (false) {
- url = "https://bugzilla.mozilla.org/buglist.cgi?query_format=advanced"
- + "field0-0-0=product;type0-0-0=regexp;"
- + "value0-0-0=thunderbird|firefox|xulrunner"
- + searchText.replace("&", ";");
- jetpack.tabs.open(url);
- }
+ urlStr += searchText;
+ tabs.open({url: urlStr});
}
};
@@ -599,13 +586,7 @@ RHBugzillaPage.prototype.queryInNewTab = function(text, component, product) {
* function this.queryInNewTab, and run it.
*/
RHBugzillaPage.prototype.queryForSelection = function() {
- var text = jetpack.selection.text;
- console.log("selection = " + text);
- if (!text) {
- text = clip.get();
- console.log("clipboard = " + text);
- }
- console.log("text = " + text);
+ var text = this.getSelectionOrClipboard();
if (text) {
this.queryInNewTab(text, this.component);
}
@@ -616,16 +597,18 @@ RHBugzillaPage.prototype.queryForSelection = function() {
*/
RHBugzillaPage.prototype.queryUpstream = function() {
console.log("Querying upstream!");
- var text = jetpack.selection.text;
- console.log("Selection = |" + text + "|");
- if (!text) {
- text = clip.get();
- }
+ var text = this.getSelectionOrClipboard();
if (text) {
text = encodeURIComponent(text.trim());
var queryUpstreamBugsURLArray = this.constantData.queryUpstreamBug;
- var url = util.filterByRegexp(queryUpstreamBugsURLArray, this.component);
- jetpack.tabs.open(url + text);
+ var urlBase = util.filterByRegexp(queryUpstreamBugsURLArray, this.component);
+ tabs.open({
+ url: urlBase + text,
+ inBackground: true,
+ onOpen: function (t) {
+ t.activate();
+ }
+ });
}
};
@@ -633,19 +616,22 @@ RHBugzillaPage.prototype.queryUpstream = function() {
*
*/
RHBugzillaPage.prototype.sendBugUpstream = function() {
- var url = util.filterByRegexp(this.constantData.newUpstreamBug, this
+ var that = this;
+ var urlStr = util.filterByRegexp(this.constantData.newUpstreamBug, this
.getOptionValue("component"));
- var ret = jetpack.tabs.open(url);
- var that = this;
- jetpack.tabs.onReady(function() {
- var otherDoc = ret.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();
- ret.focus();
+ var ret = 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();
+ ret.focus();
+ }
});
};