aboutsummaryrefslogtreecommitdiffstats
path: root/bugzillaBugTriage.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-04-29 17:33:51 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-04-29 17:33:51 +0200
commit389997c33d6e66768e3effa407939b7a94612a42 (patch)
tree048e98f4742ce824320b2a89e80320ab14338f15 /bugzillaBugTriage.js
parentc93b8f5ced2c9949f097c9daee2746df4727a8e4 (diff)
downloadbugzilla-triage-389997c33d6e66768e3effa407939b7a94612a42.tar.gz
More rearrangements to push more stuff to generic BZPage object.
Diffstat (limited to 'bugzillaBugTriage.js')
-rw-r--r--bugzillaBugTriage.js359
1 files changed, 180 insertions, 179 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js
index 6dc00a9..d8f2ebf 100644
--- a/bugzillaBugTriage.js
+++ b/bugzillaBugTriage.js
@@ -147,7 +147,7 @@ XMLRPCMessage.prototype.xml = function() {
xml += "<param>\n";
xml += "<value>"
- + XMLRPCMessage.getParamXML(XMLRPCMessage.dataTypeOf(data),
+ + this.getParamXML(this.dataTypeOf(data),
data) + "</value>\n";
xml += "</param>\n";
@@ -224,7 +224,7 @@ XMLRPCMessage.prototype.doArrayXML = function(data) {
var xml = "<array><data>\n";
for ( var i = 0; i < data.length; i++) {
xml += "<value>"
- + XMLRPCMessage.getParamXML(XMLRPCMessage.dataTypeOf(data[i]),
+ + this.getParamXML(this.dataTypeOf(data[i]),
data[i]) + "</value>\n";
}
xml += "</data></array>\n";
@@ -237,7 +237,7 @@ XMLRPCMessage.prototype.doStructXML = function(data) {
xml += "<member>\n";
xml += "<name>" + i + "</name>\n";
xml += "<value>"
- + XMLRPCMessage.getParamXML(XMLRPCMessage.dataTypeOf(data[i]),
+ + this.getParamXML(this.dataTypeOf(data[i]),
data[i]) + "</value>\n";
xml += "</member>\n";
}
@@ -249,19 +249,19 @@ XMLRPCMessage.prototype.getParamXML = function(type, data) {
var xml;
switch (type) {
case "date":
- xml = XMLRPCMessage.doDateXML(data);
+ xml = this.doDateXML(data);
break;
case "array":
- xml = XMLRPCMessage.doArrayXML(data);
+ xml = this.doArrayXML(data);
break;
case "struct":
- xml = XMLRPCMessage.doStructXML(data);
+ xml = this.doStructXML(data);
break;
case "boolean":
- xml = XMLRPCMessage.doBooleanXML(data);
+ xml = this.doBooleanXML(data);
break;
default:
- xml = XMLRPCMessage.doValueXML(type, data);
+ xml = this.doValueXML(type, data);
break;
}
return xml;
@@ -724,6 +724,21 @@ BZPage.prototype.clickMouse = function(target) {
};
/**
+ * format date to be in ISO format (just day part)
+ *
+ * @param date
+ * @return string with the formatted date
+ */
+BZPage.prototype.getISODate = function (dateStr) {
+ function pad(n) {
+ return n < 10 ? '0' + n : n;
+ }
+ var date = new Date(dateStr);
+ return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-'
+ + pad(date.getDate());
+};
+
+/**
* select element of the array where regexp in the first element matches second
* parameter of this function
*
@@ -747,6 +762,163 @@ BZPage.prototype.filterByRegexp = function(list, chosingMark) {
}
};
+/**
+ * Add text to the text box (comment box or status whiteboard)
+ *
+ * @param id
+ * string with the id of the element
+ * @param string2BAdded
+ * string to be added to the comment box
+ *
+ * @return none
+ */
+BZPage.prototype.addTextToTextBox = function(id, string2BAdded) {
+ var textBox = this.doc.getElementById(id);
+ var separator = ", ";
+ if (textBox.tagName.toLowerCase() === "textarea") {
+ separator = "\n\n";
+ } else {
+ // don't add string if it is already there
+ if (textBox.value.indexOf(string2BAdded) != -1) {
+ return;
+ }
+ }
+
+ // don't remove the current content of the comment box,
+ // just behave accordingly
+ if (textBox.value.length > 0) {
+ textBox.value = textBox.value.trim() + separator;
+ }
+ textBox.value = textBox.value + string2BAdded;
+};
+
+/**
+ * Add new keyword among the keywords.
+ *
+ * @param str
+ * string with the new keyword
+ * @return none
+ *
+ * Checks for the existing keywords.
+ */
+BZPage.prototype.addKeyword = function(str) {
+ this.addTextToTextBox("keywords", str);
+};
+
+/**
+ * generalized hasKeyword ... search in the value of the box with given id
+ *
+ * @param id
+ * String with ID of the element we want to check
+ * @param str
+ * String to be searched for
+ * @return Boolean found?
+ */
+BZPage.prototype.idContainsWord = function(id, str) {
+ try {
+ var kwd = this.doc.getElementById(id).value;
+ } catch (e) {
+ // For those who don't have particular element at all or if it is empty
+ return false;
+ }
+ console.log("id = " + id + ", kwd = " + kwd.trim());
+ return (kwd.trim().indexOf(str) != -1);
+};
+
+/**
+ * Check for the presence of a keyword
+ *
+ * @param str
+ * string with the keyword
+ * @return Boolean
+ */
+BZPage.prototype.hasKeyword = function(str) {
+ return (this.idContainsWord('keywords', str));
+};
+
+/**
+ * Set additional keyword if it isn't there
+ *
+ * @param str
+ * string with the keyword
+ * @return none
+ */
+BZPage.prototype.setKeyword = function(str) {
+ this.addTextToTextBox('keywords', str);
+};
+
+BZPage.prototype.getOptionValue = function(id) {
+ // Some special bugs don't have version for example
+ try {
+ return this.doc.getElementById(id).value;
+ } catch (e) {
+ console.error("Failed to find element with id = " + id);
+ return "#NA";
+ }
+};
+
+/**
+ * Generic function to add new button to the page. Actually copies new button
+ * from the old one (in order to have the same look-and-feel, etc.
+ *
+ * @param originalLocation
+ * object after which the new button will be added
+ * @param newId
+ * string with the id of the new button; has to be unique in whole
+ * page
+ * @param newLabel
+ * string with the label which will be shown to user
+ * @param commentString
+ * string with comment to be added to the comment box
+ * @param nState
+ * string with the new state bug should switch to (see
+ * generalPurposeCureForAllDisease function for details)
+ * @param secPar
+ * string with second parameter for generalPurposeForAllDisease
+ * @param doSubmit
+ * bool optional whether the button should submit whole page (default
+ * true)
+ *
+ * @return none
+ */
+BZPage.prototype.addNewButton = function(originalLocation, newId, newLabel,
+ commentString, nState, secPar, doSubmit, after) {
+ var that = this;
+ var commStr = "";
+ if (doSubmit === undefined) { // missing optional argument
+ doSubmit = false;
+ }
+ if (after === undefined) { // missing optional argument
+ after = false;
+ }
+ if (msgStrs[commentString]) {
+ commStr = msgStrs[commentString];
+ }
+ var newButton = this.doc.createElement("input");
+ newButton.setAttribute("id", newId);
+ if (doSubmit) {
+ newButton.setAttribute("type", "submit");
+ } else {
+ newButton.setAttribute("type", "button");
+ }
+ newButton.value = newLabel;
+ newButton.addEventListener("click", function(evt) {
+ that.generalPurposeCureForAllDisease(commStr, nState, secPar);
+ }, false);
+
+ if (after) {
+ originalLocation.parentNode.insertBefore(newButton,
+ originalLocation.nextSibling);
+ originalLocation.parentNode.insertBefore(this.doc
+ .createTextNode("\u00A0"), newButton);
+ } else {
+ originalLocation.parentNode.insertBefore(newButton, originalLocation);
+ originalLocation.parentNode.insertBefore(this.doc
+ .createTextNode("\u00A0"), originalLocation);
+ }
+};
+
+
// ====================================================================================
// MozillaBugzilla object
@@ -1013,73 +1185,6 @@ function RHBugzillaPage(doc) {
RHBugzillaPage.prototype = BZPage.prototype.create();
-/**
- * format date to be in ISO format (just day part)
- *
- * @param date
- * @return string with the formatted date
- */
-RHBugzillaPage.prototype.getISODate = function (dateStr) {
- function pad(n) {
- return n < 10 ? '0' + n : n;
- }
- var date = new Date(dateStr);
- return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-'
- + pad(date.getDate());
-};
-
-/**
- * generalized hasKeyword ... search in the value of the box with given id
- *
- * @param id
- * String with ID of the element we want to check
- * @param str
- * String to be searched for
- * @return Boolean found?
- */
-RHBugzillaPage.prototype.idContainsWord = function(id, str) {
- try {
- var kwd = this.doc.getElementById(id).value;
- } catch (e) {
- // For those who don't have particular element at all or if it is empty
- return false;
- }
- console.log("id = " + id + ", kwd = " + kwd.trim());
- return (kwd.trim().indexOf(str) != -1);
-};
-
-/**
- * Check for the presence of a keyword
- *
- * @param str
- * string with the keyword
- * @return Boolean
- */
-RHBugzillaPage.prototype.hasKeyword = function(str) {
- return (this.idContainsWord('keywords', str));
-};
-
-/**
- * Set additional keyword if it isn't there
- *
- * @param str
- * string with the keyword
- * @return none
- */
-RHBugzillaPage.prototype.setKeyword = function(str) {
- this.addTextToTextBox('keywords', str);
-};
-
-RHBugzillaPage.prototype.getOptionValue = function(id) {
- // Some special bugs don't have version for example
- try {
- return this.doc.getElementById(id).value;
- } catch (e) {
- console.error("Failed to find element with id = " + id);
- return "#NA";
- }
-};
-
/* Offline supporting functions */
/**
*
@@ -1262,49 +1367,6 @@ RHBugzillaPage.prototype.getVersion = function() {
return verNo;
};
-/**
- * Add text to the text box (comment box or status whiteboard)
- *
- * @param id
- * string with the id of the element
- * @param string2BAdded
- * string to be added to the comment box
- *
- * @return none
- */
-RHBugzillaPage.prototype.addTextToTextBox = function(id, string2BAdded) {
- var textBox = this.doc.getElementById(id);
- var separator = ", ";
- if (textBox.tagName.toLowerCase() === "textarea") {
- separator = "\n\n";
- } else {
- // don't add string if it is already there
- if (textBox.value.indexOf(string2BAdded) != -1) {
- return;
- }
- }
-
- // don't remove the current content of the comment box,
- // just behave accordingly
- if (textBox.value.length > 0) {
- textBox.value = textBox.value.trim() + separator;
- }
- textBox.value = textBox.value + string2BAdded;
-};
-
-/**
- * Add new keyword among the keywords.
- *
- * @param str
- * string with the new keyword
- * @return none
- *
- * Checks for the existing keywords.
- */
-RHBugzillaPage.prototype.addKeyword = function(str) {
- this.addTextToTextBox("keywords", str);
-};
-
RHBugzillaPage.prototype.commentsWalker = function(fce) {
var comments = this.doc.getElementById("comments").getElementsByClassName(
"bz_comment");
@@ -1525,67 +1587,6 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) {
};
/**
- * Generic function to add new button to the page. Actually copies new button
- * from the old one (in order to have the same look-and-feel, etc.
- *
- * @param originalLocation
- * object after which the new button will be added
- * @param newId
- * string with the id of the new button; has to be unique in whole
- * page
- * @param newLabel
- * string with the label which will be shown to user
- * @param commentString
- * string with comment to be added to the comment box
- * @param nState
- * string with the new state bug should switch to (see
- * generalPurposeCureForAllDisease function for details)
- * @param secPar
- * string with second parameter for generalPurposeForAllDisease
- * @param doSubmit
- * bool optional whether the button should submit whole page (default
- * true)
- *
- * @return none
- */
-RHBugzillaPage.prototype.addNewButton = function(originalLocation, newId, newLabel,
- commentString, nState, secPar, doSubmit, after) {
- var that = this;
- var commStr = "";
- if (doSubmit === undefined) { // missing optional argument
- doSubmit = false;
- }
- if (after === undefined) { // missing optional argument
- after = false;
- }
- if (msgStrs[commentString]) {
- commStr = msgStrs[commentString];
- }
- var newButton = this.doc.createElement("input");
- newButton.setAttribute("id", newId);
- if (doSubmit) {
- newButton.setAttribute("type", "submit");
- } else {
- newButton.setAttribute("type", "button");
- }
- newButton.value = newLabel;
- newButton.addEventListener("click", function(evt) {
- that.generalPurposeCureForAllDisease(commStr, nState, secPar);
- }, false);
-
- if (after) {
- originalLocation.parentNode.insertBefore(newButton,
- originalLocation.nextSibling);
- originalLocation.parentNode.insertBefore(this.doc
- .createTextNode("\u00A0"), newButton);
- } else {
- originalLocation.parentNode.insertBefore(newButton, originalLocation);
- originalLocation.parentNode.insertBefore(this.doc
- .createTextNode("\u00A0"), originalLocation);
- }
-};
-
-/**
* Get attached Xorg.0.log, parse it and find the value of chip. Does not fill
* the whiteboard itself, just adds button to do so,paramList so that slow
* XMLHttpRequest is done in advance.