aboutsummaryrefslogtreecommitdiffstats
path: root/data/lib/bugzillaDOMFunctions.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-05-07 00:53:06 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-06-05 14:53:46 +0200
commit8e501abd49e5aeac70a84ceef96a72b5078df221 (patch)
tree2cb8df170588aaee5872b752d11d6a6c39a766cc /data/lib/bugzillaDOMFunctions.js
parent59d6e1bf4e439febbc40c15486303e12febb7e42 (diff)
downloadbugzilla-triage-8e501abd49e5aeac70a84ceef96a72b5078df221.tar.gz
Another massive cleanup and simplification of tweak scripts.
bugs on bugzilla.mozilla.org now work as well, although the history is still not shown inline, which remains for 1.1. Fixes #88
Diffstat (limited to 'data/lib/bugzillaDOMFunctions.js')
-rw-r--r--data/lib/bugzillaDOMFunctions.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/data/lib/bugzillaDOMFunctions.js b/data/lib/bugzillaDOMFunctions.js
index 7d9bca5..6823bc1 100644
--- a/data/lib/bugzillaDOMFunctions.js
+++ b/data/lib/bugzillaDOMFunctions.js
@@ -265,6 +265,47 @@ function commentsWalker (fce) {
});
}
+
+/**
+ * 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
*