aboutsummaryrefslogtreecommitdiffstats
path: root/data/tweaks
diff options
context:
space:
mode:
Diffstat (limited to 'data/tweaks')
-rw-r--r--data/tweaks/bug-page-mod.js115
1 files changed, 99 insertions, 16 deletions
diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js
index 32672b0..5c922b4 100644
--- a/data/tweaks/bug-page-mod.js
+++ b/data/tweaks/bug-page-mod.js
@@ -82,6 +82,25 @@ function tweakBugzilla(things, cData) {
// when this rewrite is done
viewAttachmentSource(atts);
+/*
+
++ if (!d.getElementById("comments")) // don't process the mid-air collision
++ // pages
++ return;
++
++ // Make the comment box bigger
++ var commentBox = d.querySelector("#comment");
++ if (commentBox)
++ commentBox.rows=20;
++
++ addNewLinks(d);
++
++ attachmentDiffLinkify(d);
++
++ viewAttachmentSource(d);
+
+ */
+
// Mark up history along right hand edge
var historyLink = document.querySelector("link[title='Bug Activity']");
if (!historyLink)
@@ -108,7 +127,24 @@ function tweakBugzilla(things, cData) {
'.bztw_historyitem.bztw_cc + .bztw_historyitem:before { content: ""; }' +
'.bztw_historyitem:not([class~="bztw_cc"]) ~ .bztw_historyitem.bztw_cc + .bztw_historyitem:before { content: "; "; }'
));
- document.getElementsByTagName("head")[0].appendChild(style);
+ d.getElementsByTagName("head")[0].appendChild(style);
+
+ // UserNameCache
+ var userNameCache = {};
+
+ // Get <a> element indexed by email of a commenter (with cache)
+ function getUserName(email) {
+ if (email in userNameCache) {
+ return userNameCache[email];
+ }
+ var emailLink = d.querySelectorAll("a.email");
+ for (var i = 0; i < emailLink.length; ++i) {
+ if (emailLink[i].href == "mailto:" + email) {
+ return userNameCache[email] = htmlEncode(trimContent(emailLink[i]));
+ }
+ }
+ return email;
+ }
// collect the flag names, FIXME this is exactly the same as
// mozFlags._init() function in mozpage.js
@@ -268,6 +304,9 @@ function displayCommentActions (comment, historyItem) {
}
}
+// FIXME workhorse of all the process ... this should be fixed to work with
+// preloaded arrays of comments and history ... this comment is
+// most likely outdated.
function processHistoryItem(objects, itemRaw) {
console.log("processHistoryItem: itemRaw = " + itemRaw.toSource());
@@ -591,6 +630,38 @@ var reviewBoardUrlBase = "http://reviews.visophyte.org/";
// ===============================================================================
+/**
+ * Whenever we find a patch with a diff, insert an additional link to asuth's
+ * review board magic.
+ */
+function attachmentDiffLinkify(doc) {
+ var bug_id = getBugNo();
+
+ var table = doc.getElementById("attachment_table");
+ if (!table)
+ return;
+ var rows = table.querySelectorAll("tr");
+ for (var i = 0; i < rows.length; ++i) {
+ var item = rows[i].querySelectorAll("td");
+ if (item.length != 3)
+ continue;
+ // get the ID of the attachment
+ var links = item[2].querySelectorAll("a");
+ if (links.length != 2)
+ continue;
+ var match = reAttachmentDiff.exec(links[1].href);
+ if (match) {
+ var attach_id = match[1];
+ var parentNode = links[1].parentNode;
+ parentNode.appendChild(doc.createTextNode(" | "));
+ var linkNode = doc.createElement("a");
+ linkNode.href = reviewBoardUrlBase + "r/bzpatch/bug" + bug_id + "/attach" + attach_id + "/";
+ linkNode.textContent = "Review";
+ parentNode.appendChild(linkNode);
+ }
+ }
+}
+
function AttachmentFlagHandlerCtor() {
this._db = {};
this._interestingFlags = {};
@@ -756,9 +827,9 @@ function CheckinCommentCtor() {
this.checkinFlags = "";
}
CheckinCommentCtor.prototype = {
- initialize: function(flags) {
+ initialize: function(doc, flags) {
this.bugNumber = getBugNo();
- var summarySpan = document.getElementById("short_desc_nonedit_display");
+ var summarySpan = doc.getElementById("short_desc_nonedit_display");
if (summarySpan) {
this.summary = summarySpan.textContent;
}
@@ -879,7 +950,7 @@ function DataStoreCtor() {
}
DataStoreCtor.prototype = {
- initialize: function() {
+ initialize: function(doc) {
this.bugNumber = getBugNo();
var data = this._ensureEntry(this.bugNumber, this.data);
// last visited date
@@ -978,27 +1049,39 @@ DataStoreCtor.prototype = {
_reAttachmentHref: /attachment\.cgi\?id=(\d+)$/i
};
+// FIXME Not sure whether this fits here at all.
+// +function getUserName(doc) {
+// + var links = doc.querySelectorAll("#header .links li");
+// + var last = links[links.length - 1];
+// + if (last.innerHTML.indexOf("logout") >= 0) {
+// + return trimContent(last.lastChild);
+// + }
+// + return null;
+// +}
+
function handleEmptyCollapsedBoxes() {
// first, try to get the display style of a CC field (any would do)
- var historyBoxes = document.querySelectorAll(".bztw_history");
- for (var i = 0; i < historyBoxes.length; ++i) {
- var box = historyBoxes[i];
- for (var j = 0; j < box.childNodes.length; ++j) {
- var child = box.childNodes[j], found = true;
+ var historyBoxes = doc.querySelectorAll(".bztw_history");
+ Array.forEach(historyBoxes, function (box) {
+ Array.forEach(box.childNodes, function (child) {
+ var found = true;
if (child.nodeType != child.ELEMENT_NODE)
- continue;
+ return;
if (child.className == "sep") {
// separators are insignificant
- continue;
+ return;
} else if (!/bztw_cc/.test(child.className)) {
found = false;
- break;
+ break; // FIXME This is wrong ... we are not in cycle anymore.
}
}
- if (found) {
- box.className += " bztw_cc";
- }
- }
+// FIXME I don't get found value out of the forEach cycle
+// The fact that found is supposed to leak out of the cycle is
+// sign of something wrong going on.
+// if (found) {
+// box.className += " bztw_cc";
+// }
+ });
}
function applyClass(class_, html) {