diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-05-07 00:53:06 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-06-05 14:53:46 +0200 |
commit | 8e501abd49e5aeac70a84ceef96a72b5078df221 (patch) | |
tree | 2cb8df170588aaee5872b752d11d6a6c39a766cc /data/tweaks/viewSource.js | |
parent | 59d6e1bf4e439febbc40c15486303e12febb7e42 (diff) | |
download | bugzilla-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/tweaks/viewSource.js')
-rw-r--r-- | data/tweaks/viewSource.js | 58 |
1 files changed, 19 insertions, 39 deletions
diff --git a/data/tweaks/viewSource.js b/data/tweaks/viewSource.js index fd47cec..d2a9fd1 100644 --- a/data/tweaks/viewSource.js +++ b/data/tweaks/viewSource.js @@ -37,55 +37,33 @@ var reAttachmentType = /,\s+([^ )]*)[;)]/; -function viewAttachmentSource(doc) { - function addLink(elem, title, href) { - if (elem.textContent.match(/[\S]/)) { - elem.appendChild(doc.createTextNode(" | ")); - } - var link = doc.createElement("a"); - link.href = href; - link.textContent = title; - elem.appendChild(link); - } - var table = doc.getElementById("attachment_table"); - if (!table) - return; - var rows = table.querySelectorAll("tr"); - for ( var i = 0; i < rows.length; ++i) { - var items = rows[i].querySelectorAll("td"); - if (items.length != 3) - continue; - var links = items[0].querySelectorAll("a"); - if (links.length == 0) - continue; - var attachHref = links[0].href; - // get the type of the attachment - var span = items[0].querySelector(".bz_attach_extra_info"); - if (!span) - continue; - var typeName = null; - try { - // Match mime type followed by ";" (charset) or ")" (no charset) - typeName = span.textContent.match(reAttachmentType)[1]; - typeName = typeName.split(";")[0]; // ignore charset following type - } - catch (e) { +function viewAttachmentSource(attachments) { + attachments.forEach(function (att) { + if (att.length < 1) { + return ; } + var typeName = att[2]; + var elem = att[4]; + var id = att[1]; + var attachHref = elem.getAttribute("href"); + if (typeName == "application/java-archive" || typeName == "application/x-jar") { // Due to the fix for bug 369814, only zip files with this special // mime type can be used with the jar: protocol. // http://hg.mozilla.org/mozilla-central/rev/be54f6bb9e1e - addLink(items[2], "JAR Contents", "jar:" + attachHref - + "!/"); + // signature of addLink is addLink(elem, title, href) + // // https://bugzilla.mozilla.org/show_bug.cgi?id=369814#c5 has more // possible mime types for zips? + createDeadLink("viewSourceJAR_" + id, "JAR Contents", elem, + "jar:" + attachHref + "!/", [], "pipe", null, null); } else if (typeName == "application/zip" || typeName == "application/x-zip-compressed" || typeName == "application/x-xpinstall") { - addLink(items[2], "Static ZIP Contents", "jar:" - + attachHref + "!/"); + createDeadLink("viewSourceZIP_" + id, "Static ZIP Contents", elem, + "jar:" + attachHref + "!/", [], "pipe", null, null); } else if (typeName != "text/plain" && typeName != "patch" && // Other types that Gecko displays like text/plain @@ -98,7 +76,9 @@ function viewAttachmentSource(doc) { // Binary image types for which the "source" is not useful typeName != "image/gif" && typeName != "image/png" && typeName != "image/jpeg") { - addLink(items[2], "Source", "view-source:" + attachHref); + createDeadLink("viewSourcePlain_" + id, "Source", elem, + "view-source:" + attachHref, [], "pipe", null, null); + } } - } + ) } |