aboutsummaryrefslogtreecommitdiffstats
path: root/data/bzpage.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-01-20 17:51:29 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-01-20 17:51:29 +0100
commita8d92b4d8ef27e216b33781e014a35f55bf1be42 (patch)
tree3400885e5678ee6f963caf73e0818cf5efc6e72a /data/bzpage.js
parent8b145a758d12871e705adbd7689598edd5dfa6c3 (diff)
downloadbugzilla-triage-a8d92b4d8ef27e216b33781e014a35f55bf1be42.tar.gz
First rough removal of objects and transformation on plain functions.
TODO: * still this is all around the place * constructors has not been fixed * all require's were just yanked, but they are still used. * functions should be more self-contained ... tons of global variables everywhere.
Diffstat (limited to 'data/bzpage.js')
-rw-r--r--data/bzpage.js367
1 files changed, 177 insertions, 190 deletions
diff --git a/data/bzpage.js b/data/bzpage.js
index 37c53d2..7538b80 100644
--- a/data/bzpage.js
+++ b/data/bzpage.js
@@ -2,18 +2,6 @@
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
"use strict";
-var util = require("util");
-var passUtils = require("passwords");
-var apiUtils = require("api-utils");
-var selfMod = require("self");
-var clip = require("clipboard");
-var preferences = require("preferences-service");
-var selection = require("selection");
-var prompts = require("prompts");
-var Request = require("request").Request;
-var tabs = require("tabs");
-var Color = require("color").Color;
-
var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id=";
// Shared contstants
@@ -36,114 +24,11 @@ NotLoggedinException.prototype.toString = function () {
exports.NotLoggedinException = NotLoggedinException;
// ====================================================================================
-// BZPage's methods
-var BZPage = function BZPage(win, config) {
- // constants
- this.SalmonPink = new Color(255, 224, 176); // RGB 255, 224, 176; HSL 36, 2,
- // 85
- this.ReporterColor = new Color(255, 255, 166); // RGB 255, 255, 166; HSL 60, 2,
- // 83
-
- // initialize dynamic properties
- var that = this;
- this.win = win;
- this.doc = win.document;
- this.hostname = this.win.location.hostname;
-
- // First, preflight check ... if we are not logged in, there
- // is nothing we can do.
- var logoutLink = Array.some(this.doc.links, function (x) {
- return x.search === "?logout=1" ;
- });
- if (!logoutLink) {
- throw new NotLoggedinException("Not logged in");
- }
-
- // So, now we know we are logged in, so we can get to
- // the real work.
- this.packages = this.getInstalledPackages(config);
-
- if ("commentStrings" in config.gJSONData) {
- this.commentStrings = config.gJSONData.commentStrings;
- }
-
- this.constantData = {};
- if ("constantData" in config.gJSONData) {
- this.constantData = config.gJSONData.constantData;
- this.constantData.queryUpstreamBug = JSON.parse(
- selfMod.data.load("queryUpstreamBug.json"));
- this.constantData.XMLRPCData = JSON.parse(
- selfMod.data.load("XMLRPCdata.json"));
- }
-
- if ("CCmaintainer" in this.constantData) {
- this.defBugzillaMaintainerArr = this.constantData.CCmaintainer;
- }
-
- if ("suspiciousComponents" in config.gJSONData.configData) {
- this.suspiciousComponents = config.gJSONData.configData.suspiciousComponents;
- }
-
- if ("XorgLogAnalysis" in config.gJSONData.configData) {
- this.xorglogAnalysis = config.gJSONData.configData.XorgLogAnalysis;
- }
-
- if ("submitsLogging" in config.gJSONData.configData &&
- config.gJSONData.configData.submitsLogging) {
- this.log = config.logger;
- this.setUpLogging();
- }
-
- if ("killNodes" in config.gJSONData.configData &&
- this.hostname in config.gJSONData.configData.killNodes) {
- var killConf = config.gJSONData.configData.killNodes[this.hostname];
- util.killNodes(this.doc, killConf[0], killConf[1]);
- }
-
- this.setConfigurationButton();
- this.submitHandlerInstalled = false;
-
- this.login = this.getLogin();
- // XML-RPC password
- if (this.hostname in this.constantData.XMLRPCData) {
- this.password = this.getPassword(this.login);
- }
-
- this.bugNo = util.getBugNo(this.doc.location.toString());
-
- // deal with aliases
- if (isNaN(parseInt(this.bugNo, 10)) && this.password) {
- this.bugNo = this.getRealBugNo();
- }
-
- this.title = this.doc.getElementById("short_desc_nonedit_display").textContent;
- this.CCList = this.getCCList();
-
- // Prepare for query buttons
- // element ID brElementPlace_location is later used in JSON files
- // Stay with this add_comment element even if RH BZ upgrades, this seems
- // to be generally much more stable (even with other bugzillas, e.g. b.gnome.org)
- // then some getElementById.
- var commentArea = this.doc.getElementsByName("add_comment")[0].parentNode;
- if (commentArea) {
- var brElementPlacer = commentArea.getElementsByTagName("br");
- brElementPlacer = brElementPlacer[0];
- if (brElementPlacer) {
- brElementPlacer.setAttribute("id","brElementPlacer_location");
- brElementPlacer.parentNode.insertBefore(this.doc.createElement("br"),
- brElementPlacer);
- }
- }
-
- this.checkComments();
- this.generateButtons();
-};
-
/**
* In case URL contains alias, not the real bug number, get the real bug no
* from the XML representation. Sets correct value to this.bugNo.
*/
-BZPage.prototype.getRealBugNo = function () {
+function getRealBugNo() {
console.log("We have to deal with bug aliased as " + this.bugNo);
var that = this;
// https://bugzilla.redhat.com/show_bug.cgi?ctype=xml&id=serialWacom
@@ -161,12 +46,12 @@ BZPage.prototype.getRealBugNo = function () {
}
}
}).get();
-};
+}
/**
*
*/
-BZPage.prototype.getInstalledPackages = function getInstalledPackages(cfg) {
+function getInstalledPackages(cfg) {
var installedPackages = {};
var enabledPackages = [];
@@ -196,7 +81,7 @@ BZPage.prototype.getInstalledPackages = function getInstalledPackages(cfg) {
});
}
return installedPackages;
-};
+}
/**
* Actual execution function
@@ -204,7 +89,7 @@ BZPage.prototype.getInstalledPackages = function getInstalledPackages(cfg) {
* @param cmdLabel String with the name of the command to be executed
* @param cmdParams Object with the appropriate parameters for the command
*/
-BZPage.prototype.centralCommandDispatch = function centralCommandDispatch (cmdLabel, cmdParams) {
+function centralCommandDispatch (cmdLabel, cmdParams) {
switch (cmdLabel) {
case "resolution":
case "product":
@@ -295,7 +180,7 @@ BZPage.prototype.centralCommandDispatch = function centralCommandDispatch (cmdLa
}
break;
}
-};
+}
/**
* Take the ID of the package/id combination, and execute it
@@ -313,14 +198,14 @@ BZPage.prototype.centralCommandDispatch = function centralCommandDispatch (cmdLa
* everywhere except of Internet Explorer this should work well, but waiting
* impatiently when this bite us.
*/
-BZPage.prototype.executeCommand = function executeCommand (cmd) {
+function executeCommand (cmd) {
var cmdArr = cmd.split("//");
var commentObj = this.packages[cmdArr[0]][cmdArr[1]];
for (var key in commentObj) {
this.centralCommandDispatch(key,commentObj[key]);
}
-};
+}
/**
* Change assignee of the bug
@@ -330,7 +215,7 @@ BZPage.prototype.executeCommand = function executeCommand (cmd) {
* Value null clears "Reset Assignee to default for component" checkbox
* @return none
*/
-BZPage.prototype.changeAssignee = function changeAssignee (newAssignee) {
+function changeAssignee (newAssignee) {
var defAssigneeButton = null;
// Previous assignee should know what's going on in his bug
this.addToCCList(this.owner);
@@ -362,7 +247,7 @@ BZPage.prototype.changeAssignee = function changeAssignee (newAssignee) {
defAssigneeButton.style.display = "none";
}
}
-};
+}
/**
* Adds new option to the 'comment_action' scroll down box
@@ -372,7 +257,7 @@ BZPage.prototype.changeAssignee = function changeAssignee (newAssignee) {
* If the 'comment_action' scroll down box doesn't exist, this
* function will set up new one.
*/
-BZPage.prototype.addToCommentsDropdown = function addToCommentsDropdown (pkg, cmd) {
+function addToCommentsDropdown (pkg, cmd) {
var select = this.doc.getElementById("comment_action");
if (!select) {
var that = this;
@@ -401,7 +286,7 @@ BZPage.prototype.addToCommentsDropdown = function addToCommentsDropdown (pkg, cm
opt.value = pkg + "//" + cmd;
opt.textContent = this.packages[pkg][cmd].name;
select.appendChild(opt);
-};
+}
/**
* Create a A element leadink nowhere, but with listener running a callback on the click
@@ -414,7 +299,7 @@ BZPage.prototype.addToCommentsDropdown = function addToCommentsDropdown (pkg, cm
* @param Boolean breakBefore if there should be a <br> element before.
* @return none
*/
-BZPage.prototype.createDeadLink = function createDeadLink (id, text, parent, callback, params, before, covered, accesskey) {
+function createDeadLink (id, text, parent, callback, params, before, covered, accesskey) {
var that = this;
params = util.valToArray(params);
var locParent = {};
@@ -448,7 +333,7 @@ BZPage.prototype.createDeadLink = function createDeadLink (id, text, parent, cal
}
locParent.appendChild(newAElem);
-};
+}
/**
@@ -461,7 +346,7 @@ BZPage.prototype.createDeadLink = function createDeadLink (id, text, parent, cal
* @param id String which command to take
* @return none
*/
-BZPage.prototype.createNewButton = function createNewButton (location, after, pkg, id) {
+function createNewButton (location, after, pkg, id) {
var that = this;
var cmdObj = this.packages[pkg][id];
var newId = id + "_btn";
@@ -508,12 +393,12 @@ BZPage.prototype.createNewButton = function createNewButton (location, after, pk
throw e;
}
}
-};
+}
/**
*
*/
-BZPage.prototype.generateButtons = function generateButtons () {
+function generateButtons () {
var topRowPosition = "topRowPositionID";
var bottomRowPosition = "commit";
@@ -545,9 +430,9 @@ BZPage.prototype.generateButtons = function generateButtons () {
}
}
}
-};
+}
-BZPage.prototype.setConfigurationButton = function setConfigurationButton () {
+function setConfigurationButton () {
var additionalButtons = this.doc.querySelector("#bugzilla-body *.related_actions");
var configurationButtonUI = this.doc.createElement("li");
configurationButtonUI.innerHTML = "\u00A0-\u00A0<a href='' id='configurationButton'>"
@@ -568,7 +453,7 @@ BZPage.prototype.setConfigurationButton = function setConfigurationButton () {
evt.stopPropagation();
evt.preventDefault();
}, false);
-};
+}
/*
* From <a> element diggs out just plain email address
@@ -579,7 +464,7 @@ BZPage.prototype.setConfigurationButton = function setConfigurationButton () {
* @return String with the address or null
*
*/
-BZPage.prototype.parseMailto = function parseMailto(aElement) {
+function parseMailto(aElement) {
var emailStr = "", hrefStr = "";
// use url utils
if (aElement) {
@@ -593,14 +478,14 @@ BZPage.prototype.parseMailto = function parseMailto(aElement) {
return emailStr;
}
return null;
-};
+}
/**
* Get the current email of the reporter of the bug.
*
* @return string
*/
-BZPage.prototype.getReporter = function getReporter () {
+function getReporter () {
var reporterElement = this.getOptionTableCell("bz_show_bug_column_2", "Reported");
// RH Bugzilla after upgrade to 3.6.2 moved the information to other column
if (!reporterElement) {
@@ -609,30 +494,30 @@ BZPage.prototype.getReporter = function getReporter () {
// Maemo calls the label "Reporter" and it doesn't have ids on table columns ... TODO(maemo)
return this.parseMailto(reporterElement);
-};
+}
-BZPage.prototype.getComponent = function getComponent() {
+function getComponent() {
var elem = this.doc.getElementById("component");
if (elem) {
return elem.value;
}
return null;
-};
+}
-BZPage.prototype.commentsWalker = function commentsWalker (fce) {
+function commentsWalker (fce) {
var comments = this.doc.getElementById("comments").getElementsByClassName(
"bz_comment");
Array.forEach(comments, function(item) {
fce(item);
}, this);
-};
+}
/**
* Set background color of all comments made by reporter in ReporterColor color
*
*/
-BZPage.prototype.checkComments = function checkComments () {
+function checkComments () {
var that = this;
var reporterRE = new RegExp(this.getReporter());
this.commentsWalker(function(x) {
@@ -642,15 +527,15 @@ BZPage.prototype.checkComments = function checkComments () {
x.style.backgroundColor = that.ReporterColor.toString();
}
});
-};
+}
-BZPage.prototype.collectComments = function collectComments () {
+function collectComments () {
var outStr = "";
this.commentsWalker(function(x) {
outStr += x.getElementsByTagName("pre")[0].textContent + "\n";
});
return outStr.trim();
-};
+}
/**
@@ -663,7 +548,7 @@ BZPage.prototype.collectComments = function collectComments () {
* @return none
*
*/
-BZPage.prototype.selectOption = function selectOption (id, label, fireEvent) {
+function selectOption (id, label, fireEvent) {
if (!fireEvent) {
fireEvent = true;
}
@@ -674,9 +559,9 @@ BZPage.prototype.selectOption = function selectOption (id, label, fireEvent) {
intEvent.initEvent("change", true, true);
sel.dispatchEvent(intEvent);
}
-};
+}
-BZPage.prototype.selectOptionByLabel = function selectOptionByLabel(id, label, fireEvent) {
+function selectOptionByLabel(id, label, fireEvent) {
if (!fireEvent) {
fireEvent = true;
}
@@ -695,7 +580,7 @@ BZPage.prototype.selectOptionByLabel = function selectOptionByLabel(id, label, f
intEvent.initEvent("change", true, true);
sel.dispatchEvent(intEvent);
}
-};
+}
/**
* Send mouse click to the specified element
@@ -703,12 +588,12 @@ BZPage.prototype.selectOptionByLabel = function selectOptionByLabel(id, label, f
* @param String ID of the element to send mouseclick to
* @return None
*/
-BZPage.prototype.clickMouse = function clickMouse (targetID) {
+function clickMouse (targetID) {
var localEvent = this.doc.createEvent("MouseEvents");
localEvent.initMouseEvent("click", true, true, this.doc.defaultView, 0, 0,
0, 0, 0, false, false, false, false, 0, null);
this.doc.getElementById(targetID).dispatchEvent(localEvent);
-};
+}
/**
* Add object to the text box (comment box or status whiteboard)
@@ -718,7 +603,7 @@ BZPage.prototype.clickMouse = function clickMouse (targetID) {
*
* @return none
*/
-BZPage.prototype.addStuffToTextBox = function addStuffToTextBox (id, stuff) {
+function addStuffToTextBox (id, stuff) {
var textBox = this.doc.getElementById(id);
if (textBox.tagName.toLowerCase() === "textarea") {
stuff = textBox.value ? "\n\n" + stuff : stuff;
@@ -726,7 +611,7 @@ BZPage.prototype.addStuffToTextBox = function addStuffToTextBox (id, stuff) {
} else {
textBox.value = util.addCSVValue(textBox.value,stuff);
}
-};
+}
/**
* Remove a keyword from the element if it is there
@@ -734,10 +619,10 @@ BZPage.prototype.addStuffToTextBox = function addStuffToTextBox (id, stuff) {
* @param id String with the id of the element
* @param stuff String/Array with keyword(s) to be removed
*/
-BZPage.prototype.removeStuffFromTextBox = function removeStuffFromTextBox (id, stuff) {
+function removeStuffFromTextBox (id, stuff) {
var changedElement = this.getElementById(id);
changedElement.value = util.removeCSVValue(changedElement.value,stuff);
-};
+}
/**
* generalized hasKeyword ... search in the value of the box with given id
@@ -746,7 +631,7 @@ BZPage.prototype.removeStuffFromTextBox = function removeStuffFromTextBox (id, s
* @param str String to be searched for
* @return Boolean found?
*/
-BZPage.prototype.idContainsWord = function idContainsWord (id, str) {
+function idContainsWord (id, str) {
var kwd = "";
try {
kwd = this.doc.getElementById(id).value;
@@ -755,7 +640,7 @@ BZPage.prototype.idContainsWord = function idContainsWord (id, str) {
return false;
}
return (util.isInList(str, kwd.trim().split(/[,\s]+/)));
-};
+}
/**
* Check for the presence of a keyword
@@ -763,15 +648,15 @@ BZPage.prototype.idContainsWord = function idContainsWord (id, str) {
* @param str String with the keyword
* @return Boolean
*/
-BZPage.prototype.hasKeyword = function hasKeyword (str) {
+function hasKeyword (str) {
return (this.idContainsWord('keywords', str));
-};
+}
/**
@return Element with the href attribute containng the information
*/
-BZPage.prototype.getOptionTableCell = function getOptionTableCell(tableId, label) {
+function getOptionTableCell(tableId, label) {
var cleanLabelRE = /^\s*([^.:]*):?\s*$/;
label = label.trim().replace(cleanLabelRE,"$1").toLowerCase();
@@ -787,7 +672,7 @@ BZPage.prototype.getOptionTableCell = function getOptionTableCell(tableId, label
getElementsByTagName("a")[0];
}
return null;
-};
+}
/**
* Set the bug to NEEDINFO state
@@ -797,19 +682,19 @@ BZPage.prototype.getOptionTableCell = function getOptionTableCell(tableId, label
* @todo TODO we may extend this to general setNeedinfo function
* with parameter [reporter|assignee|general-email-address]
*/
-BZPage.prototype.setNeedinfoReporter = function setNeedinfoReporter () {
+function setNeedinfoReporter () {
this.clickMouse("needinfo");
this.selectOption("needinfo_role", "reporter");
-};
+}
/**
*
*/
-BZPage.prototype.getOwner = function getOwner () {
+function getOwner () {
// TODO(maemo) doesn't work on maemo
var assigneeAElement = this.getOptionTableCell("bz_show_bug_column_1","Assigned To");
return this.parseMailto(assigneeAElement);
-};
+}
/**
* Return maintainer which is per default by bugzilla
@@ -817,10 +702,10 @@ BZPage.prototype.getOwner = function getOwner () {
*
* @return String with the maintainer's email address
*/
-BZPage.prototype.getDefaultBugzillaMaintainer = function getDefaultBugzillaMaintainer (component) {
+function getDefaultBugzillaMaintainer (component) {
var address = util.filterByRegexp(this.defBugzillaMaintainerArr, component);
return address;
-};
+}
/**
* Parse the row with the attachment
@@ -830,7 +715,8 @@ BZPage.prototype.getDefaultBugzillaMaintainer = function getDefaultBugzillaMaint
* string of MIME type, integer of size in kilobytes, and the whole
* element itself
*/
-BZPage.prototype.parseAttachmentLine = function(inElem) {
+
+function parseAttachmentLine(inElem) {
var MIMEtype = "";
var size = 0;
@@ -857,7 +743,7 @@ BZPage.prototype.parseAttachmentLine = function(inElem) {
MIMEtype = stringArray[1].split(" ")[0];
return [ attName, id, MIMEtype, size, inElem ];
-};
+}
/**
* collect the list of attachments in a structured format
@@ -867,7 +753,7 @@ BZPage.prototype.parseAttachmentLine = function(inElem) {
* string of MIME type, integer of size in kilobytes, and the whole
* element itself
*/
-BZPage.prototype.getAttachments = function getAttachments () {
+function getAttachments () {
var outAtts = [];
var atts = this.doc.getElementById("attachment_table")
.getElementsByTagName("tr");
@@ -875,19 +761,19 @@ BZPage.prototype.getAttachments = function getAttachments () {
outAtts.push(this.parseAttachmentLine(atts[i]));
}
return outAtts;
-};
+}
/**
* Get login of the currently logged-in user.
*
* @return String with the login name of the currently logged-in user
*/
-BZPage.prototype.getLogin = function getLogin () {
+function getLogin () {
var lastLIElement = this.doc.querySelector("#header ul.links li:last-of-type");
var loginArr = lastLIElement.textContent.split("\n");
var loginStr = loginArr[loginArr.length - 1].trim();
return loginStr;
-};
+}
/**
* returns password from the current storage, or if there isn't
@@ -895,7 +781,7 @@ BZPage.prototype.getLogin = function getLogin () {
*
* @return String with the password
*/
-BZPage.prototype.getPassword = function getPassword (login) {
+function getPassword (login) {
var passPrompt = "Enter your Bugzilla password for fixing MIME attachment types";
var switchPrompt = "Do you want to switch off features requiring password completely?";
var prefName = BTSPrefNS+"withoutPassowrd";
@@ -919,12 +805,12 @@ BZPage.prototype.getPassword = function getPassword (login) {
} else {
return pass;
}
-};
+}
/**
*
*/
-BZPage.prototype.setUpLogging = function setUpLogging () {
+function setUpLogging () {
// Protection against double-call
if (this.doc.getElementById("generateTSButton")) {
return ;
@@ -972,15 +858,15 @@ BZPage.prototype.setUpLogging = function setUpLogging () {
clearLogAElem.style.color = this.log.FullLogsColor;
clearLogAElem.style.fontWeight = "bolder";
}
-};
+}
-BZPage.prototype.getSelectionOrClipboard = function 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
@@ -992,7 +878,7 @@ BZPage.prototype.getSelectionOrClipboard = function getSelectionOrClipboard () {
* @return None
*
*/
-BZPage.prototype.queryInNewTab = function(text, component, product) {
+function queryInNewTab(text, component, product) {
var urlStr = "https://bugzilla.redhat.com/buglist.cgi?query_format=advanced";
if (product) {
urlStr += "&product=" + product.trim();
@@ -1034,18 +920,18 @@ BZPage.prototype.queryInNewTab = function(text, component, product) {
}
});
}
-};
+}
/**
* Get the text to search for and prepare other things for the real executive
* function this.queryInNewTab, and run it.
*/
-BZPage.prototype.queryForSelection = function() {
+function queryForSelection() {
var text = this.getSelectionOrClipboard();
if (text) {
this.queryInNewTab(text, this.getComponent());
}
-};
+}
/**
* adds a person to the CC list, if it isn't already there
@@ -1053,7 +939,7 @@ BZPage.prototype.queryForSelection = function() {
* @param who String with email address or "self" if the current user
* of the bugzilla should be added
*/
-BZPage.prototype.addToCCList = function addToCCList (who) {
+function addToCCList (who) {
if (!who) {
return ;
}
@@ -1065,14 +951,14 @@ BZPage.prototype.addToCCList = function addToCCList (who) {
this.addStuffToTextBox("newcc",who);
}
}
-};
+}
/**
* a collect a list of emails on CC list
*
* @return Array with email addresses as Strings.
*/
-BZPage.prototype.getCCList = function getCCList () {
+function getCCList () {
var CCListSelect = this.doc.getElementById("cc");
var outCCList = [];
if (CCListSelect) {
@@ -1081,7 +967,108 @@ BZPage.prototype.getCCList = function getCCList () {
});
}
return outCCList;
-};
+}
// exports.BZPage = apiUtils.publicConstructor(BZPage);
-exports.BZPage = BZPage;
+// BZPage's methods
+var BZPage = function BZPage(win, config) {
+ // constants
+ this.SalmonPink = new Color(255, 224, 176); // RGB 255, 224, 176; HSL 36, 2,
+ // 85
+ this.ReporterColor = new Color(255, 255, 166); // RGB 255, 255, 166; HSL 60, 2,
+ // 83
+
+ // initialize dynamic properties
+ var that = this;
+ this.win = win;
+ this.doc = win.document;
+ this.hostname = this.win.location.hostname;
+
+ // First, preflight check ... if we are not logged in, there
+ // is nothing we can do.
+ var logoutLink = Array.some(this.doc.links, function (x) {
+ return x.search === "?logout=1" ;
+ });
+ if (!logoutLink) {
+ throw new NotLoggedinException("Not logged in");
+ }
+
+ // So, now we know we are logged in, so we can get to
+ // the real work.
+ this.packages = this.getInstalledPackages(config);
+
+ if ("commentStrings" in config.gJSONData) {
+ this.commentStrings = config.gJSONData.commentStrings;
+ }
+
+ this.constantData = {};
+ if ("constantData" in config.gJSONData) {
+ this.constantData = config.gJSONData.constantData;
+ this.constantData.queryUpstreamBug = JSON.parse(
+ selfMod.data.load("queryUpstreamBug.json"));
+ this.constantData.XMLRPCData = JSON.parse(
+ selfMod.data.load("XMLRPCdata.json"));
+ }
+
+ if ("CCmaintainer" in this.constantData) {
+ this.defBugzillaMaintainerArr = this.constantData.CCmaintainer;
+ }
+
+ if ("suspiciousComponents" in config.gJSONData.configData) {
+ this.suspiciousComponents = config.gJSONData.configData.suspiciousComponents;
+ }
+
+ if ("XorgLogAnalysis" in config.gJSONData.configData) {
+ this.xorglogAnalysis = config.gJSONData.configData.XorgLogAnalysis;
+ }
+
+ if ("submitsLogging" in config.gJSONData.configData &&
+ config.gJSONData.configData.submitsLogging) {
+ this.log = config.logger;
+ this.setUpLogging();
+ }
+
+ if ("killNodes" in config.gJSONData.configData &&
+ this.hostname in config.gJSONData.configData.killNodes) {
+ var killConf = config.gJSONData.configData.killNodes[this.hostname];
+ util.killNodes(this.doc, killConf[0], killConf[1]);
+ }
+
+ this.setConfigurationButton();
+ this.submitHandlerInstalled = false;
+
+ this.login = this.getLogin();
+ // XML-RPC password
+ if (this.hostname in this.constantData.XMLRPCData) {
+ this.password = this.getPassword(this.login);
+ }
+
+ this.bugNo = util.getBugNo(this.doc.location.toString());
+
+ // deal with aliases
+ if (isNaN(parseInt(this.bugNo, 10)) && this.password) {
+ this.bugNo = this.getRealBugNo();
+ }
+
+ this.title = this.doc.getElementById("short_desc_nonedit_display").textContent;
+ this.CCList = this.getCCList();
+
+ // Prepare for query buttons
+ // element ID brElementPlace_location is later used in JSON files
+ // Stay with this add_comment element even if RH BZ upgrades, this seems
+ // to be generally much more stable (even with other bugzillas, e.g. b.gnome.org)
+ // then some getElementById.
+ var commentArea = this.doc.getElementsByName("add_comment")[0].parentNode;
+ if (commentArea) {
+ var brElementPlacer = commentArea.getElementsByTagName("br");
+ brElementPlacer = brElementPlacer[0];
+ if (brElementPlacer) {
+ brElementPlacer.setAttribute("id","brElementPlacer_location");
+ brElementPlacer.parentNode.insertBefore(this.doc.createElement("br"),
+ brElementPlacer);
+ }
+ }
+
+ this.checkComments();
+ this.generateButtons();
+};