diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-07-29 18:07:09 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-09-17 17:08:14 +0200 |
commit | c58186483beffd3bc6261ae8c2ccb0b932b33304 (patch) | |
tree | 79364a042377f2412f0cb8d6ff37a2d7fe38c27b /lib/bzpage.js | |
parent | 5172d8d70e9bc0ed8ea2808128eb42596513f4bb (diff) | |
download | bugzilla-triage-c58186483beffd3bc6261ae8c2ccb0b932b33304.tar.gz |
Some thoughts on the backtrace showing
Diffstat (limited to 'lib/bzpage.js')
-rw-r--r-- | lib/bzpage.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js index 635ec7d..cbaae12 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -774,6 +774,43 @@ BZPage.prototype.getDefaultBugzillaMaintainer = function getDefaultBugzillaMaint }; /** + * 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 + */ +BZPage.prototype.parseAttachmentLine = function(inElem) { + var MIMEtype = ""; + var size = 0; + + // Skip over obsolete attachments + if (inElem.getElementsByClassName("bz_obsolete").length > 0) { + return ( []); + } + + // getting name of the attachment + // TODO probably could use url.URL object + var attName = inElem.getElementsByTagName("b")[0].textContent.trim(); + + var aHrefsArr = inElem.getElementsByTagName("a"); + var aHref = Array.filter(aHrefsArr, function(x) { + return x.textContent.trim() === "Details"; + })[0]; + var id = parseInt(aHref.getAttribute("href").replace( + /^.*attachment.cgi\?id=/, ""), 10); + + // 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; |