aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bzpage.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bzpage.js')
-rw-r--r--lib/bzpage.js86
1 files changed, 48 insertions, 38 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js
index 79f6d64..d155ea5 100644
--- a/lib/bzpage.js
+++ b/lib/bzpage.js
@@ -16,6 +16,8 @@ var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id=";
// BZPage's methods
var BZPage = exports.BZPage = function BZPage(doc, config) {
+ console.log("doc = " + doc);
+ console.log("config = " + config);
// constants
this.SalmonPink = new Color(255, 224, 176); // RGB 255, 224, 176; HSL 36, 2,
// 85
@@ -24,11 +26,28 @@ var BZPage = exports.BZPage = function BZPage(doc, config) {
// initialize dynamic properties
this.doc = doc;
console.log("this.doc = " + this.doc);
+
+ this.submitHandlerInstalled = false;
+ this.bugNo = util.getBugNo(this.doc.location.toString());
+
+ var keys = "";
+ for (var key in this) {
+ keys += key + ", ";
+ }
+ console.log("keys = " + keys);
+
+ this.reporter = this.getReporter();
+ this.product = this.getOptionValue("product");
+ this.component = this.getOptionValue("component");
+ this.version = this.getVersion();
+ this.title = this.doc.getElementById("short_desc_nonedit_display").textContent;
+ this.CCList = this.getCCList();
+
this.packages = this.getInstalledPackages();
+
if ("commentStrings" in config.gJSONData) {
this.commentStrings = config.gJSONData.commentStrings;
}
-
if ("constantData" in config.gJSONData) {
// this is wrong, I shouldn't bother anybody with my Xorg data, and
@@ -47,22 +66,13 @@ var BZPage = exports.BZPage = function BZPage(doc, config) {
this.setUpLogging();
}
- this.submitHandlerInstalled = false;
- this.bugNo = util.getBugNo(this.doc.location.toString());
- this.reporter = this.getReporter();
- this.product = this.getOptionValue("product");
- this.component = this.getOptionValue("component");
- this.version = this.getVersion();
- this.title = this.doc.getElementById("short_desc_nonedit_display").textContent;
- this.CCList = this.getCCList();
-
this.generateButtons();
};
/**
*
*/
-BZPage.prototype.getInstalledPackages = function() {
+BZPage.prototype.getInstalledPackages = function getInstalledPackages() {
var installedPackages = {};
if (config.gJSONData && ("commentPackages" in config.gJSONData)) {
var enabledPackages = jetpack.storage.settings.enabledPacks.split(/[, ]/);
@@ -81,7 +91,7 @@ BZPage.prototype.getInstalledPackages = function() {
* @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 (cmdLabel, cmdParams) {
+BZPage.prototype.centralCommandDispatch = function centralCommandDispatch (cmdLabel, cmdParams) {
switch (cmdLabel) {
case "resolution":
case "product":
@@ -179,7 +189,7 @@ BZPage.prototype.centralCommandDispatch = function (cmdLabel, cmdParams) {
* goes through all commands contained in it, and calls
* this.centralCommandDispatch to execute them.
*/
-BZPage.prototype.executeCommand = function(cmd) {
+BZPage.prototype.executeCommand = function executeCommand (cmd) {
var cmdArr = cmd.split("//");
var commentObj = this.packages[cmdArr[0]][cmdArr[1]];
@@ -194,7 +204,7 @@ BZPage.prototype.executeCommand = function(cmd) {
* @param evt Event which made this function active
* @return none
*/
-BZPage.prototype.changeAssignee = function(newAssignee) {
+BZPage.prototype.changeAssignee = function changeAssignee (newAssignee) {
var defAssigneeButton = null;
this.addToCCList(this.owner);
if (newAssignee === null) {
@@ -233,7 +243,7 @@ BZPage.prototype.changeAssignee = function(newAssignee) {
* If the 'comment_action' scroll down box doesn't exist, this
* function will set up new one.
*/
-BZPage.prototype.addToCommentsDropdown = function(pkg, cmd) {
+BZPage.prototype.addToCommentsDropdown = function addToCommentsDropdown (pkg, cmd) {
var select = this.doc.getElementById("comment_action");
if (!select) {
var that = this;
@@ -272,7 +282,7 @@ BZPage.prototype.addToCommentsDropdown = function(pkg, cmd) {
* @param id String which command to take
* @return none
*/
-BZPage.prototype.createNewButton = function(location, after, pkg, id) {
+BZPage.prototype.createNewButton = function createNewButton (location, after, pkg, id) {
var that = this;
var cmdObj = this.packages[pkg][id];
var newId = id + "_btn";
@@ -316,7 +326,7 @@ BZPage.prototype.createNewButton = function(location, after, pkg, id) {
/**
*
*/
-BZPage.prototype.generateButtons = function() {
+BZPage.prototype.generateButtons = function generateButtons () {
var topRowPosition = "topRowPositionID";
var bottomRowPosition = "commit";
@@ -355,7 +365,7 @@ BZPage.prototype.generateButtons = function() {
*
* @return string
*/
-BZPage.prototype.getReporter = function() {
+BZPage.prototype.getReporter = function getReporter () {
return this.doc
.querySelector("#bz_show_bug_column_2 > table .vcard:first-of-type > a").textContent;
};
@@ -366,7 +376,7 @@ BZPage.prototype.getReporter = function() {
*
* @return string (integer for released Fedora, float for RHEL, rawhide)
*/
-BZPage.prototype.getVersion = function() {
+BZPage.prototype.getVersion = function getVersion () {
var verStr = this.getOptionValue("version").toLowerCase();
var verNo = 0;
if (/rawhide/.test(verStr)) {
@@ -377,7 +387,7 @@ BZPage.prototype.getVersion = function() {
return verNo;
};
-BZPage.prototype.commentsWalker = function(fce) {
+BZPage.prototype.commentsWalker = function commentsWalker (fce) {
var comments = this.doc.getElementById("comments").getElementsByClassName(
"bz_comment");
Array.forEach(comments, function(item) {
@@ -389,7 +399,7 @@ BZPage.prototype.commentsWalker = function(fce) {
* Set background color of all comments made by reporter in ReporterColor color
*
*/
-BZPage.prototype.checkComments = function() {
+BZPage.prototype.checkComments = function checkComments () {
var that = this;
this.commentsWalker(function(x) {
var email = x.getElementsByClassName("vcard")[0]
@@ -400,7 +410,7 @@ BZPage.prototype.checkComments = function() {
});
};
-BZPage.prototype.collectComments = function() {
+BZPage.prototype.collectComments = function collectComments () {
var outStr = "";
this.commentsWalker(function(x) {
outStr += x.getElementsByTagName("pre")[0].textContent + "\n";
@@ -423,7 +433,7 @@ BZPage.prototype.collectComments = function() {
var doc = select[0].ownerDocument;
select.val(value);
*/
-BZPage.prototype.selectOption = function(id, label) {
+BZPage.prototype.selectOption = function selectOption (id, label) {
var sel = this.doc.getElementById(id);
sel.value = label;
var intEvent = this.doc.createEvent("HTMLEvents");
@@ -437,7 +447,7 @@ BZPage.prototype.selectOption = function(id, label) {
* @param String ID of the element to send mouseclick to
* @return None
*/
-BZPage.prototype.clickMouse = function(targetID) {
+BZPage.prototype.clickMouse = 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);
@@ -452,7 +462,7 @@ BZPage.prototype.clickMouse = function(targetID) {
*
* @return none
*/
-BZPage.prototype.addStuffToTextBox = function(id, stuff) {
+BZPage.prototype.addStuffToTextBox = function addStuffToTextBox (id, stuff) {
var textBox = this.doc.getElementById(id);
if (textBox.tagName.toLowerCase() === "textarea") {
stuff = textBox.value ? "\n\n" + stuff : stuff;
@@ -468,7 +478,7 @@ BZPage.prototype.addStuffToTextBox = function(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(id, stuff) {
+BZPage.prototype.removeStuffFromTextBox = function removeStuffFromTextBox (id, stuff) {
var changedElement = this.getElementById(id);
changedElement.value = util.removeCSVValue(changedElement.value,stuff);
};
@@ -480,7 +490,7 @@ BZPage.prototype.removeStuffFromTextBox = function(id, stuff) {
* @param str String to be searched for
* @return Boolean found?
*/
-BZPage.prototype.idContainsWord = function(id, str) {
+BZPage.prototype.idContainsWord = function idContainsWord (id, str) {
var kwd = "";
try {
kwd = this.doc.getElementById(id).value;
@@ -497,14 +507,14 @@ BZPage.prototype.idContainsWord = function(id, str) {
* @param str String with the keyword
* @return Boolean
*/
-BZPage.prototype.hasKeyword = function(str) {
+BZPage.prototype.hasKeyword = function hasKeyword (str) {
return (this.idContainsWord('keywords', str));
};
/**
*
*/
-BZPage.prototype.getOptionValue = function(id) {
+BZPage.prototype.getOptionValue = function getOptionValue (id) {
// Some special bugs don't have version for example
var element = this.doc.getElementById(id);
if (element) {
@@ -523,7 +533,7 @@ BZPage.prototype.getOptionValue = function(id) {
* @todo TODO we may extend this to general setNeedinfo function
* with parameter [reporter|assignee|general-email-address]
*/
-BZPage.prototype.setNeedinfoReporter = function() {
+BZPage.prototype.setNeedinfoReporter = function setNeedinfoReporter () {
this.clickMouse("needinfo");
this.selectOption("needinfo_role", "reporter");
};
@@ -531,7 +541,7 @@ BZPage.prototype.setNeedinfoReporter = function() {
/**
*
*/
-BZPage.prototype.getOwner = function() {
+BZPage.prototype.getOwner = function getOwner () {
var priorityParent = this.doc.querySelector("label[for~='target_milestone']")
.parentNode.parentNode.parentNode;
var assigneeAElement = priorityParent.querySelector("tr:nth-of-type(1) a.email");
@@ -545,7 +555,7 @@ BZPage.prototype.getOwner = function() {
*
* @return String with the login name of the currently logged-in user
*/
-BZPage.prototype.getLogin = function () {
+BZPage.prototype.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();
@@ -558,7 +568,7 @@ BZPage.prototype.getLogin = function () {
*
* @return String with the maintainer's email address
*/
-BZPage.prototype.getDefaultBugzillaMaintainer = function(component) {
+BZPage.prototype.getDefaultBugzillaMaintainer = function getDefaultBugzillaMaintainer (component) {
var address = util.filterByRegexp(this.defBugzillaMaintainerArr, component);
return address;
};
@@ -571,7 +581,7 @@ BZPage.prototype.getDefaultBugzillaMaintainer = function(component) {
* string of MIME type, integer of size in kilobytes, and the whole
* element itself
*/
-BZPage.prototype.getAttachments = function() {
+BZPage.prototype.getAttachments = function getAttachments () {
var outAtts = [];
var atts = this.doc.getElementById("attachment_table")
.getElementsByTagName("tr");
@@ -587,7 +597,7 @@ BZPage.prototype.getAttachments = function() {
*
* @return String with the password
*/
-BZPage.prototype.getPassword = function() {
+BZPage.prototype.getPassword = function getPassword () {
if (jetpack.storage.settings.BZpassword) {
return jetpack.storage.settings.BZpassword;
} else {
@@ -617,7 +627,7 @@ BZPage.prototype.getPassword = function() {
/**
*
*/
-BZPage.prototype.setUpLogging = function() {
+BZPage.prototype.setUpLogging = function setUpLogging () {
// For adding additional buttons to the top toolbar
var additionalButtons = this.doc.querySelector("#bugzilla-body *.related_actions");
var that = this;
@@ -688,7 +698,7 @@ BZPage.prototype.setUpLogging = function() {
* @param who String with email address or "self" if the current user
* of the bugzilla should be added
*/
-BZPage.prototype.addToCCList = function(who) {
+BZPage.prototype.addToCCList = function addToCCList (who) {
if (!who) {
return ;
}
@@ -707,7 +717,7 @@ BZPage.prototype.addToCCList = function(who) {
*
* @return Array with email addresses as Strings.
*/
-BZPage.prototype.getCCList = function() {
+BZPage.prototype.getCCList = function getCCList () {
var CCListSelect = this.doc.getElementById("cc");
outCCList = [];
if (CCListSelect) {