aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--data/bzpage.js367
-rw-r--r--data/mozillabzpage.js19
-rw-r--r--data/rhbzpage.js369
-rw-r--r--lib/main.js66
4 files changed, 414 insertions, 407 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();
+};
diff --git a/data/mozillabzpage.js b/data/mozillabzpage.js
deleted file mode 100644
index 31f6332..0000000
--- a/data/mozillabzpage.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// Released under the MIT/X11 license
-// http://www.opensource.org/licenses/mit-license.php
-"use strict";
-var utilMod = require("util");
-var apiUtils = require("api-utils");
-var BZPage = require("bzpage").BZPage;
-
-// ============================================================================
-// MozillaBugzilla object
-
-var MozillaBugzilla = function MozillaBugzilla (doc, config) {
- BZPage.call(this, doc, config);
-};
-
-MozillaBugzilla.prototype = utilMod.heir(BZPage);
-MozillaBugzilla.prototype.constructor = MozillaBugzilla;
-
-// exports.MozillaBugzilla = apiUtils.publicConstructor(MozillaBugzilla);
-exports.MozillaBugzilla = MozillaBugzilla; \ No newline at end of file
diff --git a/data/rhbzpage.js b/data/rhbzpage.js
index 3cb21e6..d4d071a 100644
--- a/data/rhbzpage.js
+++ b/data/rhbzpage.js
@@ -2,159 +2,21 @@
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
"use strict";
-var util = require("util");
-var xrpc = require("xmlrpc");
-var apiUtils = require("api-utils");
-var self = require("self");
-var Color = require("color").Color;
-var BZPage = require("bzpage").BZPage;
-var Request = require("request").Request;
-var url = require("url");
-var timer = require("timer");
-var selection = require("selection");
-var tabs = require("tabs");
var NumberOfFrames = require("bzpage").NumberOfFrames;
var titleParsedAttachment = "Part of the thread where crash happened";
// ====================================================================================
// RHBugzillaPage object
-var RHBugzillaPage = function RHBugzillaPage(win, config) {
- // inheritance ... call superobject's constructor
- BZPage.call(this, win, config);
-
- // For identification of graphics card
- this.manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ],
- [ "ATI Mobility Radeon", "ATI", "1002" ],
- [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ];
-
- // http://en.wikipedia.org/wiki/HSL_color_space
- // when only the value of S is changed
- // stupido!!! the string is value in hex for each color
- this.RHColor = new Color(158, 41, 43); // RGB 158, 41, 43; HSL 359, 1, 39
- this.FedoraColor = new Color(0, 40, 103); // RGB 0, 40, 103; HSL 359, 1, 39
- this.RawhideColor = new Color(0, 119, 0); // or "green", or RGB 0, 119, 0, or
- // HSL
- // 120, 0, 23
- this.RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20
-
- this.RE = {
- Comment: new RegExp("^\\s*#"), // unsused
- BlankLine: new RegExp("^\\s*$"), // unused
- // new line
- // [ 65.631] (--) intel(0): Chipset: "845G"
- Chipset: new RegExp("^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+
- "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$"),
- ATIgetID: new RegExp("^.*\\(ChipID = 0x([0-9a-fA-F]+)\\).*$"),
- Abrt: new RegExp("^\\s*\\[abrt\\]"),
- signalHandler: new RegExp("^\\s*#[0-9]*\\s*<signal handler called>"),
- frameNo: new RegExp("^\\s*#([0-9]*)\\s"),
- soughtLines: new RegExp("^\\s*(\\[[0-9 .]*\\])?\\s*(\\((EE|WW)\\)|.* [cC]hipsets?: )|\\s*Backtrace")
- };
- // END OF CONSTANTS
-
- var that = this;
- this.reqCounter = 0;
- this.signaturesCounter = 0;
- this.chipMagicInterestingLine = "";
-
- this.product = this.doc.getElementById("product").value;
-
- this.maintCCAddr = null;
- if (this.constantData.CCmaintainer) {
- this.maintCCAddr = util.filterByRegexp(this.constantData.CCmaintainer,
- this.getComponent());
- }
-
- var ITbutton = this.doc.getElementById("cf_issuetracker");
- this.its = ITbutton ? ITbutton.value.trim() : "";
-
- if (!this.constantData.ProfessionalProducts) {
- this.constantData.ProfessionalProducts =
- JSON.parse(self.data.load("professionalProducts.json"));
- }
-
- // getBadAttachments
- this.XorgLogAttList = [];
- this.XorgLogAttListIndex = 0;
- this.attachments = this.getAttachments();
- this.markBadAttachments(this.attachments);
-
- this.parsedAttachments = this.attachments.filter(function (att) {
- return (new RegExp(titleParsedAttachment).test(att[0]));
- });
-
- if (this.constantData.defaultAssignee) {
- this.setDefaultAssignee();
- }
-
- // Dig out backtrace protection against double-firing?
- this.btSnippet = "";
-
- var parseAbrtBacktraces = config.gJSONData.configData.parseAbrtBacktraces;
- if (parseAbrtBacktraces && this.RE.Abrt.test(this.title)) {
- this.pasteBacktraceInComments();
- }
-
- // Find out Xorg.0.log attachment URL
- this.XorgLogAttList = this.attachments.filter(function (value, index, array) {
- // Xorg.0.log must be text, otherwise we cannot parse it
- return (/[xX].*log/.test(value[0]) && /text/.test(value[2]));
- });
- this.addCheckXorgLogLink();
-
- // TODO Get compiz bugs as well
- if (this.constantData.PCI_ID_Array &&
- (this.XorgLogAttList[0]) &&
- (this.maintCCAddr === "xgl-maint@redhat.com")) {
- // Add find chip magic button
- var whiteboard_string = this.doc.getElementById("status_whiteboard").value;
- if (!/card_/.test(whiteboard_string)) {
- this.fillInChipMagic();
- }
- }
-
- // Take care of signature for Fedora bugzappers
- if (config.gJSONData.configData.signature.length > 0) {
- var signatureFedoraString = config.gJSONData.configData.signature;
- this.doc.forms.namedItem("changeform").addEventListener("submit",
- function(aEvt) {
- if (that.signaturesCounter < 1) {
- that.addStuffToTextBox("comment", signatureFedoraString);
- that.signaturesCounter += 1;
- }
- }, false);
- }
-
- this.setBranding();
-
- // set default assignee on change of the component
- var compElement = this.doc.getElementById("component");
- if (compElement && (compElement.options)) {
- this.doc.getElementById("component").addEventListener("change",
- function() {
- that.changeAssignee("default");
- }, false);
- }
-
-}; // END OF RHBugzillaPage CONSTRUCTOR
-
-RHBugzillaPage.prototype.toString = function toString () {
- return ("[Object RHBugzillaPage]");
-};
-
-RHBugzillaPage.prototype = util.heir(BZPage);
-RHBugzillaPage.prototype.constructor = RHBugzillaPage;
-
/**
* Find default assignee based on the current component
*
* @return String what would be a default assignee if
* we haven't set it up.
*/
-RHBugzillaPage.prototype.getDefaultAssignee = function() {
+function getDefaultAssignee() {
return util.filterByRegexp(this.constantData.defaultAssignee,
this.getComponent()).toLowerCase();
-};
+}
/**
* Set default assignee
@@ -162,7 +24,7 @@ RHBugzillaPage.prototype.getDefaultAssignee = function() {
* @return none
* sets this.defaultAssignee property according to defaultAssignee list
*/
-RHBugzillaPage.prototype.setDefaultAssignee = function() {
+function setDefaultAssignee() {
this.defaultAssignee = this.getDefaultAssignee();
var defAss = this.defaultAssignee;
@@ -171,12 +33,12 @@ RHBugzillaPage.prototype.setDefaultAssignee = function() {
this.constantData.defaultAssigneeTrigger = true;
this.createNewButton("bz_assignee_edit_container",true,"rh-common","setDefaultAssignee");
}
-};
+}
/**
* Auxiliary function to compute more complicated resolution
*/
-RHBugzillaPage.prototype.closeSomeRelease = function() {
+function closeSomeRelease() {
// for RAWHIDE close as RAWHIDE,
// if active selection -> CURRENTRELEASE
// and put the release version to
@@ -198,12 +60,12 @@ RHBugzillaPage.prototype.closeSomeRelease = function() {
resolution = "NEXTRELEASE";
}
this.centralCommandDispatch("resolution", resolution);
-};
+}
/**
* Additional commands specific for this subclass, overriding superclass one.
*/
-RHBugzillaPage.prototype.centralCommandDispatch = function(cmdLabel, cmdParams) {
+function RHcentralCommandDispatch(cmdLabel, cmdParams) {
console.log("cmdLabel = " + cmdLabel + ", cmdParams = " + cmdParams);
switch (cmdLabel) {
// Set up our own commands
@@ -228,17 +90,17 @@ RHBugzillaPage.prototype.centralCommandDispatch = function(cmdLabel, cmdParams)
break;
// If we don't have it here, call superclass method
default:
- BZPage.prototype.centralCommandDispatch.call(this, cmdLabel, cmdParams);
+ centralCommandDispatch.call(this, cmdLabel, cmdParams);
break;
}
-};
+}
/**
*
* This has to stay in RHBugzillaPage because upstream doesn't have addAttachment
* XML-RPC call yet.
*/
-RHBugzillaPage.prototype.addAttachment = function addAttachment(data, callback, param) {
+function addAttachment(data, callback, param) {
var msg = new xrpc.XMLRPCMessage("bugzilla.addAttachment");
var that = this;
@@ -267,13 +129,13 @@ RHBugzillaPage.prototype.addAttachment = function addAttachment(data, callback,
contentType: "text/xml"
}).post();
this.reqCounter++;
-};
+}
/* === Bugzilla functions === */
/**
*
*/
-RHBugzillaPage.prototype.pasteBacktraceInComments = function() {
+function pasteBacktraceInComments() {
var that = this;
/*
@@ -340,7 +202,7 @@ RHBugzillaPage.prototype.pasteBacktraceInComments = function() {
that.addShowParsedBTLink(att);
}, that);
}
-};
+}
/**
* Open new window with the content of the attachment.
@@ -348,7 +210,7 @@ RHBugzillaPage.prototype.pasteBacktraceInComments = function() {
* @param id Number of the attachment id
* @return none
*/
-RHBugzillaPage.prototype.showAttachment = function showAttachment(id) {
+function showAttachment(id) {
var that = this;
Request({
url: "https://" + that.hostname + "/attachment.cgi?id=" + id,
@@ -364,23 +226,23 @@ RHBugzillaPage.prototype.showAttachment = function showAttachment(id) {
}
}
}).get();
-};
+}
/**
* add a link opening a window with the parsed backtrace
*
* @param att Attachment object
*/
-RHBugzillaPage.prototype.addShowParsedBTLink = function addShowParsedBTLink(att) {
+function addShowParsedBTLink(att) {
var elem = att[4].querySelector("td:last-of-type");
this.createDeadLink("showParsedBacktraceWindow-" + att[1], "showBT",
elem, this.showAttachment, att[1], true);
-};
+}
/**
* Unfinished ... see above
*/
-RHBugzillaPage.prototype.addNewAttachmentRow = function addNewAttachmentRow(origAtt,
+function addNewAttachmentRow(origAtt,
newAttId, newAttSize) {
var that = this;
var oldAddBTLink = this.doc.getElementById("attachBacktraceActivator");
@@ -420,7 +282,7 @@ RHBugzillaPage.prototype.addNewAttachmentRow = function addNewAttachmentRow(orig
this.showAttachment, newAttId, false);
origAtt[4].parentNode.insertBefore(newTRElem, origAtt[4].nextSibling);
-};
+}
/**
* Add a link to create a new attachment with a parsed backtrace
@@ -429,7 +291,7 @@ RHBugzillaPage.prototype.addNewAttachmentRow = function addNewAttachmentRow(orig
* @param snippet String with parsed backtrace
* @return none
*/
-RHBugzillaPage.prototype.addCheckShowLink = function addCheckShowLink(oldAtt, snippet) {
+function addCheckShowLink(oldAtt, snippet) {
var that = this;
var elem = oldAtt[4].querySelector("td:last-of-type");
this.createDeadLink("attachBacktraceActivator", "add parsed BT", elem, function(x) {
@@ -437,7 +299,7 @@ RHBugzillaPage.prototype.addCheckShowLink = function addCheckShowLink(oldAtt, sn
// addAttachment
that.addAttachment.call(that, snippet, this.addNewAttachmentRow, oldAtt);
}, [], true);
-};
+}
/**
* Make it sailent that the some attachments with bad MIME type are present
@@ -445,7 +307,7 @@ RHBugzillaPage.prototype.addCheckShowLink = function addCheckShowLink(oldAtt, sn
* @param atts Array of attachments subarrays
* @return none
*/
-RHBugzillaPage.prototype.markBadAttachments = function markBadAttachments(atts) {
+function markBadAttachments(atts) {
var that = this;
var badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ];
if (!this.password) {
@@ -471,29 +333,29 @@ RHBugzillaPage.prototype.markBadAttachments = function markBadAttachments(atts)
this.addTextLink(x);
}, this);
}
-};
+}
/**
* Is this bug a RHEL bug?
*
* @return Boolean true if it is a RHEL bug
*/
-RHBugzillaPage.prototype.isEnterprise = function() {
+function isEnterprise() {
var prod = this.product;
var result = this.constantData.ProfessionalProducts.some(function(elem,idx,arr) {
return new RegExp(elem).test(prod);
});
return result;
-};
+}
/**
* Find out whether the bug is needed an attention of bugZappers
*
* @return Boolean whether the bug has been triaged or not
*/
-RHBugzillaPage.prototype.isTriaged = function() {
+function isTriaged() {
return this.hasKeyword("Triaged");
-};
+}
/**
* Set branding colours to easily distinguish between Fedora and RHEL bugs
@@ -503,7 +365,7 @@ RHBugzillaPage.prototype.isTriaged = function() {
* @param its String with the IsueTracker numbers
* @return none
*/
-RHBugzillaPage.prototype.setBranding = function() {
+function setBranding() {
var brandColor = {};
var TriagedColor = {};
@@ -567,14 +429,14 @@ RHBugzillaPage.prototype.setBranding = function() {
.getElementById("bz_component_edit_container"))) {
compElems.style.background = "red none";
}
-};
+}
/**
* Search simple query in the upstream bugzilla appropriate for the component
*
* @return none
*/
-RHBugzillaPage.prototype.queryUpstream = function() {
+function queryUpstream() {
var text = this.getSelectionOrClipboard();
if (text) {
var queryUpstreamBugsURLArray = this.constantData.queryUpstreamBug;
@@ -593,14 +455,14 @@ RHBugzillaPage.prototype.queryUpstream = function() {
}
});
}
-};
+}
/**
* Open a tab in the upstream bugzilla to create a new bug
*
* @return none
*/
-RHBugzillaPage.prototype.sendBugUpstream = function() {
+function sendBugUpstream() {
var that = this;
var urlStr = util.filterByRegexp(JSON.parse(self.data.load("newUpstreamBug.json")), this
.getComponent());
@@ -618,14 +480,14 @@ RHBugzillaPage.prototype.sendBugUpstream = function() {
tabs.activeTab = tab;
}
});
-};
+}
/**
* Add a link opening selected lines of Xorg.0.log
*
* @return none
*/
-RHBugzillaPage.prototype.addCheckXorgLogLink = function addCheckXorgLogLink() {
+function addCheckXorgLogLink() {
var that = this;
if (this.xorglogAnalysis) {
this.XorgLogAttList.forEach(function (row) {
@@ -635,7 +497,7 @@ RHBugzillaPage.prototype.addCheckXorgLogLink = function addCheckXorgLogLink() {
that.analyzeXorgLog, row[1], "br");
});
}
-};
+}
/**
* Given line to be parsed, find out which chipset it is and fill in the
@@ -645,7 +507,7 @@ RHBugzillaPage.prototype.addCheckXorgLogLink = function addCheckXorgLogLink() {
* @param driverStr String with the driver name
* @return None
*/
-RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) {
+function fillInWhiteBoard(iLine, driverStr) {
var that = this;
function groupIDs(manStr, cardStrID) {
@@ -716,7 +578,7 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) {
}
this.addStuffToTextBox("status_whiteboard", ("card_" + outStr).trim());
this.doc.getElementById("chipMagic_btn").style.display = "none";
-};
+}
/**
* Get attached Xorg.0.log, parse it and find the value of chip. Does not fill
@@ -725,7 +587,7 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) {
*
* @return None
*/
-RHBugzillaPage.prototype.fillInChipMagic = function fillInChipMagic() {
+function fillInChipMagic() {
var that = this;
var XorgLogURL = "";
var XorgLogAttID = "";
@@ -765,9 +627,9 @@ RHBugzillaPage.prototype.fillInChipMagic = function fillInChipMagic() {
}
}).get();
this.XorgLogAttListIndex++;
-};
+}
-RHBugzillaPage.prototype.analyzeXorgLog = function analyzeXorgLog(attachID) {
+function analyzeXorgLog(attachID) {
var infoWin = this.win.open("", "Check att. " + attachID,
"width=640,height=640,status=no,location=no");
var doc = infoWin.document;
@@ -806,7 +668,7 @@ RHBugzillaPage.prototype.analyzeXorgLog = function analyzeXorgLog(attachID) {
// doc.body.style.cursor = oldCursor;
}
}).get();
-};
+}
/**
* Return string with the ID for the external_id SELECT for external bugzilla
@@ -814,7 +676,7 @@ RHBugzillaPage.prototype.analyzeXorgLog = function analyzeXorgLog(attachID) {
* @param URLhostname String hostname of the external bugzilla
* @return String with the string for the external_id SELECT
*/
-RHBugzillaPage.prototype.getBugzillaName = function getBugzillaName(URLhostname) {
+function getBugzillaName(URLhostname) {
var bugzillaID = "";
var bzLabelNames = JSON.parse(self.data.load("bugzillalabelNames.json"));
if (bzLabelNames[URLhostname]) {
@@ -823,7 +685,7 @@ RHBugzillaPage.prototype.getBugzillaName = function getBugzillaName(URLhostname)
bugzillaID = "";
}
return bugzillaID;
-};
+}
/**
* Callback function for the XMLRPC request
@@ -834,7 +696,7 @@ RHBugzillaPage.prototype.getBugzillaName = function getBugzillaName(URLhostname)
* + responseHeaders
* + responseText
*/
-RHBugzillaPage.prototype.XMLRPCcallback = function XMLRPCcallback() {
+function XMLRPCcallback() {
var that = this;
this.reqCounter--;
if (this.reqCounter <= 0) {
@@ -842,7 +704,7 @@ RHBugzillaPage.prototype.XMLRPCcallback = function XMLRPCcallback() {
that.win.location.reload(true);
}, 1000);
}
-};
+}
/**
* The worker function -- call XMLRPC to fix MIME type of the particular
@@ -866,7 +728,7 @@ RHBugzillaPage.prototype.XMLRPCcallback = function XMLRPCcallback() {
* this change };
*
*/
-RHBugzillaPage.prototype.fixAttachById = function fixAttachById(id, type, email) {
+function fixAttachById(id, type, email) {
if (type === undefined) {
type = "text/plain";
}
@@ -898,7 +760,7 @@ RHBugzillaPage.prototype.fixAttachById = function fixAttachById(id, type, email)
contentType: "text/xml"
}).post();
this.reqCounter++;
-};
+}
/**
* Add a link to the bad attachment for fixing it.
@@ -907,12 +769,12 @@ RHBugzillaPage.prototype.fixAttachById = function fixAttachById(id, type, email)
* <TR> DOM jQuery element with a bad attachment
* @return none
*/
-RHBugzillaPage.prototype.addTextLink = function addTextLink(row) {
+function addTextLink(row) {
var elemS = row[4].getElementsByTagName("td");
var elem = elemS[elemS.length - 1];
this.createDeadLink("addFix2TextLink", "text", elem,
this.fixAttachById, row[1], "br");
-};
+}
/**
* Add information about the upstream bug upstream, and closing it.
@@ -920,7 +782,7 @@ RHBugzillaPage.prototype.addTextLink = function addTextLink(row) {
* @param evt Event which called this handler
* @return none
*/
-RHBugzillaPage.prototype.addClosingUpstream = function() {
+function addClosingUpstream() {
var refs = this.doc.getElementById("external_bugs_table")
.getElementsByTagName("tr");
@@ -962,9 +824,9 @@ RHBugzillaPage.prototype.addClosingUpstream = function() {
} else {
console.log("No external bug specified among the External References!");
}
-};
+}
-RHBugzillaPage.prototype.markBugTriaged = function() {
+function markBugTriaged() {
// Now we lie completely, we just set keyword Triaged,
// this is not just plain ASSIGNED, but
// modified according to
@@ -982,12 +844,12 @@ RHBugzillaPage.prototype.markBugTriaged = function() {
this.selectOption("bug_status", "ASSIGNED");
}
this.addStuffToTextBox("keywords","Triaged");
-};
+}
/**
*
*/
-RHBugzillaPage.prototype.parseBacktrace = function(ret) {
+function parseBacktrace (ret) {
var splitArray = ret.split("\n");
var i = 0, ii = splitArray.length;
var outStr = "", curLine = "", numStr = "";
@@ -1017,7 +879,124 @@ RHBugzillaPage.prototype.parseBacktrace = function(ret) {
return outStr;
}
return "";
-};
+}
+
+function RHBugzillaPage(win, config) {
+ // inheritance ... call superobject's constructor
+ BZPage.call(this, win, config);
+
+ // For identification of graphics card
+ this.manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ],
+ [ "ATI Mobility Radeon", "ATI", "1002" ],
+ [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ];
+
+ // http://en.wikipedia.org/wiki/HSL_color_space
+ // when only the value of S is changed
+ // stupido!!! the string is value in hex for each color
+ this.RHColor = new Color(158, 41, 43); // RGB 158, 41, 43; HSL 359, 1, 39
+ this.FedoraColor = new Color(0, 40, 103); // RGB 0, 40, 103; HSL 359, 1, 39
+ this.RawhideColor = new Color(0, 119, 0); // or "green", or RGB 0, 119, 0, or
+ // HSL
+ // 120, 0, 23
+ this.RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20
+
+ this.RE = {
+ Comment: new RegExp("^\\s*#"), // unsused
+ BlankLine: new RegExp("^\\s*$"), // unused
+ // new line
+ // [ 65.631] (--) intel(0): Chipset: "845G"
+ Chipset: new RegExp("^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+
+ "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$"),
+ ATIgetID: new RegExp("^.*\\(ChipID = 0x([0-9a-fA-F]+)\\).*$"),
+ Abrt: new RegExp("^\\s*\\[abrt\\]"),
+ signalHandler: new RegExp("^\\s*#[0-9]*\\s*<signal handler called>"),
+ frameNo: new RegExp("^\\s*#([0-9]*)\\s"),
+ soughtLines: new RegExp("^\\s*(\\[[0-9 .]*\\])?\\s*(\\((EE|WW)\\)|.* [cC]hipsets?: )|\\s*Backtrace")
+ };
+ // END OF CONSTANTS
+
+ var that = this;
+ this.reqCounter = 0;
+ this.signaturesCounter = 0;
+ this.chipMagicInterestingLine = "";
+
+ this.product = this.doc.getElementById("product").value;
+
+ this.maintCCAddr = null;
+ if (this.constantData.CCmaintainer) {
+ this.maintCCAddr = util.filterByRegexp(this.constantData.CCmaintainer,
+ this.getComponent());
+ }
+
+ var ITbutton = this.doc.getElementById("cf_issuetracker");
+ this.its = ITbutton ? ITbutton.value.trim() : "";
+
+ if (!this.constantData.ProfessionalProducts) {
+ this.constantData.ProfessionalProducts =
+ JSON.parse(self.data.load("professionalProducts.json"));
+ }
+
+ // getBadAttachments
+ this.XorgLogAttList = [];
+ this.XorgLogAttListIndex = 0;
+ this.attachments = this.getAttachments();
+ this.markBadAttachments(this.attachments);
+
+ this.parsedAttachments = this.attachments.filter(function (att) {
+ return (new RegExp(titleParsedAttachment).test(att[0]));
+ });
+
+ if (this.constantData.defaultAssignee) {
+ this.setDefaultAssignee();
+ }
+
+ // Dig out backtrace protection against double-firing?
+ this.btSnippet = "";
+
+ var parseAbrtBacktraces = config.gJSONData.configData.parseAbrtBacktraces;
+ if (parseAbrtBacktraces && this.RE.Abrt.test(this.title)) {
+ this.pasteBacktraceInComments();
+ }
+
+ // Find out Xorg.0.log attachment URL
+ this.XorgLogAttList = this.attachments.filter(function (value, index, array) {
+ // Xorg.0.log must be text, otherwise we cannot parse it
+ return (/[xX].*log/.test(value[0]) && /text/.test(value[2]));
+ });
+ this.addCheckXorgLogLink();
+
+ // TODO Get compiz bugs as well
+ if (this.constantData.PCI_ID_Array &&
+ (this.XorgLogAttList[0]) &&
+ (this.maintCCAddr === "xgl-maint@redhat.com")) {
+ // Add find chip magic button
+ var whiteboard_string = this.doc.getElementById("status_whiteboard").value;
+ if (!/card_/.test(whiteboard_string)) {
+ this.fillInChipMagic();
+ }
+ }
+
+ // Take care of signature for Fedora bugzappers
+ if (config.gJSONData.configData.signature.length > 0) {
+ var signatureFedoraString = config.gJSONData.configData.signature;
+ this.doc.forms.namedItem("changeform").addEventListener("submit",
+ function(aEvt) {
+ if (that.signaturesCounter < 1) {
+ that.addStuffToTextBox("comment", signatureFedoraString);
+ that.signaturesCounter += 1;
+ }
+ }, false);
+ }
+
+ this.setBranding();
+
+ // set default assignee on change of the component
+ var compElement = this.doc.getElementById("component");
+ if (compElement && (compElement.options)) {
+ this.doc.getElementById("component").addEventListener("change",
+ function() {
+ that.changeAssignee("default");
+ }, false);
+ }
-// exports.RHBugzillaPage = apiUtils.publicConstructor(RHBugzillaPage);
-exports.RHBugzillaPage = RHBugzillaPage;
+}
diff --git a/lib/main.js b/lib/main.js
index fbabd41..35d7d60 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -13,10 +13,11 @@
"use strict";
var logger = require("logger");
var browser = require("tab-browser");
-var selfMod = require("self");
+var self = require("self");
var Request = require("request").Request;
var preferences = require("preferences-service");
-var BTSPrefNS = require("bzpage").BTSPrefNS;
+var pageMod = require("page-mod");
+// var BTSPrefNS = require("bzpage").BTSPrefNS;
// Use my JSON for now before it is fixed for general public
var JSONURLDefault = "https://fedorahosted.org/released"+
"/bugzilla-triage-scripts/Config_data.json";
@@ -87,7 +88,7 @@ function initialize(callback) {
}, this);
}
- config.logger = new logger.Logger(JSON.parse(selfMod.data.load("bugzillalabelAbbreviations.json")));
+ config.logger = new logger.Logger(JSON.parse(self.data.load("bugzillalabelAbbreviations.json")));
config.matches = config.gJSONData.configData.matches;
config.skipMatches = config.matches.map(function(x) {
@@ -108,6 +109,7 @@ function initialize(callback) {
}).get();
}
+/*
exports.main = function main(options, callbacks) {
initialize(function (config) {
browser.whenContentLoaded(
@@ -132,3 +134,61 @@ exports.main = function main(options, callbacks) {
);
});
};
+
+*/
+var messageHandler = exports.messageHandler = function messageHandler(worker, msg) {
+ switch (msg.cmd) {
+ case "LogMessage":
+ console.log(msg.data);
+ break;
+ case "GetDuplicatorID":
+ getDuplicatorID(msg.data.host, msg.data.bugID, function (msgObj) {
+ worker.postMessage(msgObj);
+ });
+ break;
+ case "GetPassword":
+ getPassword(msg.data.login, msg.data.hostname, function (pass) {
+ worker.postMessage(pass);
+ });
+ break;
+ case "DeDeduplicateQueue":
+ LoginData = {
+ queue: msg.data.bugs,
+ host: msg.data.hostname,
+ login: msg.data.login,
+ pass: msg.data.password,
+ dupID: msg.data.duplicator,
+ finalCallback: function (msgObj) {
+ worker.postMessage(msgObj);
+ }
+ };
+ processReqQueue();
+ break;
+ case "testReady":
+ // we ignore it here, interesting only in unit test
+ break;
+ default:
+ console.error(msg.toSource());
+ }
+};
+
+var contentScriptLibraries = {
+ "bugzilla.redhat.com": [
+ self.data.url("bzpage.js"),
+ self.data.url("rhbzpage.js")
+ ]
+};
+
+pageMod.PageMod({
+ include: [
+ "https://bugzilla.redhat.com/show_bug.cgi?id=*"
+ ],
+ contentScriptWhen: 'ready',
+ // contentScriptFile: contentScriptLibraries["bugzilla.redhat.com"],
+ onAttach: function onAttach(worker, msg) {
+ console.log("worker: " + worker);
+ worker.on('message', function (msg) {
+ messageHandler(worker, msg);
+ });
+ }
+});