aboutsummaryrefslogtreecommitdiffstats
path: root/data/lib/bugzillaDOMFunctions.js
diff options
context:
space:
mode:
Diffstat (limited to 'data/lib/bugzillaDOMFunctions.js')
-rw-r--r--data/lib/bugzillaDOMFunctions.js93
1 files changed, 26 insertions, 67 deletions
diff --git a/data/lib/bugzillaDOMFunctions.js b/data/lib/bugzillaDOMFunctions.js
index 49afef5..98a2031 100644
--- a/data/lib/bugzillaDOMFunctions.js
+++ b/data/lib/bugzillaDOMFunctions.js
@@ -147,6 +147,32 @@ function getDefaultBugzillaMaintainer (component) {
}
/**
+ * dd
+ *
+ * @return Element with the href attribute containng the information
+ */
+function getOptionTableCell(tableId, label) {
+ var cleanLabelRE = new RegExp("^\\s*([^.:]*):?\\s*$");
+ label = label.trim().replace(cleanLabelRE,"$1").toLowerCase();
+
+ var rows = document.getElementById(tableId).getElementsByTagName("tr");
+ var ourLine = Array.filter(rows, function(row) {
+ var curLabelElems = row.getElementsByTagName("td");
+ if (curLabelElems.length > 0) {
+ var curLabel = curLabelElems[0].textContent.toLowerCase();
+ curLabel = curLabel.replace(cleanLabelRE,"$1");
+ return (curLabel === label); // maybe this could be a RE match instead
+ }
+ });
+
+ if (ourLine.length > 0) {
+ return ourLine[0].getElementsByTagName("td")[1].
+ getElementsByTagName("a")[0];
+ }
+ return null;
+}
+
+/**
* 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.
*
@@ -257,72 +283,6 @@ function getProduct() {
return null;
}
-function commentsWalker (fce) {
- var comments = document.getElementById("comments").
- getElementsByClassName("bz_comment");
- Array.forEach(comments, function(item) {
- fce(item);
- });
-}
-
-
-/**
- * Parse the row with the attachment
- *
- * @param DOM
- * element to be parsed
- * @return array with string name of the attachment, integer its id number,
- * string of MIME type, integer of size in kilobytes, and the whole
- * element itself
- *
- * TODO error handling is missing ... it's bleee
- */
-function parseAttachmentLine(inElem) {
- var MIMEtype = "";
- var size = 0;
-
- // Skip over obsolete attachments
- if (inElem.getElementsByClassName("bz_obsolete").length > 0) {
- return ([]);
- }
-
- // getting name of the attachment
- var attName = inElem.getElementsByTagName("b")[0].textContent.trim();
-
- // TODO probably could use url.URL object
- var aHrefsArr = inElem.getElementsByTagName("a");
- var aHref = Array.filter(aHrefsArr, function(x) {
- return x.textContent.trim() === "Details";
- })[0];
- var id = parseURL(aHref.getAttribute("href")).params.id;
-
- // getting MIME type and size
- var stringArray = inElem.getElementsByClassName("bz_attach_extra_info")[0].textContent.
- replace(/[\n ()]+/g, " ").trim().split(", ");
- size = parseInt(stringArray[0], 10);
- MIMEtype = stringArray[1].split(" ")[0];
-
- return [ attName, id, MIMEtype, size, inElem ];
-}
-
-
-/**
- * collect the list of attachments in a structured format
- *
- * @return Array of arrays, one for each attachments; each record has string
- * name of the attachment, integer its id number, string of MIME type,
- * integer of size in kilobytes, and the whole element itself
- */
-function getAttachments () {
- var outAtts = [];
- var atts = document.getElementById("attachment_table").
- getElementsByTagName("tr");
- for ( var i = 1, ii = atts.length - 1; i < ii; i++) {
- outAtts.push(parseAttachmentLine(atts[i]));
- }
- return outAtts;
-}
-
/**
* Get login of the currently logged-in user.
*
@@ -408,7 +368,6 @@ function killNodes(doc, target, remove) {
// removing its members.
for(var i = 0, ii = victimElements.length; i < ii; i++) {
elem = victimElements[i];
- console.myDebug("Killing element " + elem[0]);
try {
elem[1].parentNode.removeChild(elem[1]);
}