aboutsummaryrefslogtreecommitdiffstats
path: root/data/tweaks/bug-page-mod.js
diff options
context:
space:
mode:
Diffstat (limited to 'data/tweaks/bug-page-mod.js')
-rw-r--r--data/tweaks/bug-page-mod.js134
1 files changed, 84 insertions, 50 deletions
diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js
index 0af5d48..f5d154e 100644
--- a/data/tweaks/bug-page-mod.js
+++ b/data/tweaks/bug-page-mod.js
@@ -106,7 +106,9 @@ function collectHistory(rpcURL) {
}));
}
-function tweakBugzilla(atts, cData) {
+function tweakBugzilla(things, cData) {
+ var atts = things.attachments; // FIXME compatibility crutch, should be removed
+ // when this rewrite is done
viewAttachmentSource(atts);
// Mark up history along right hand edge
@@ -208,7 +210,7 @@ function tweakBugzilla(atts, cData) {
// ===================================================
function processHistory(history) {
// FIXME Remove remaining code to special function ... callback
-// preprocessDuplicateMarkers(document, iframe.contentDocument);
+ // preprocessDuplicateMarkers(document, iframe.contentDocument);
/*
* This is an example of the history we get: { "version": "1.1", "result": {
@@ -238,7 +240,6 @@ function processHistory(history) {
* ] } ], "faults": [
* ] } }
*/
-
// UserNameCache
var userNameCache = {};
function getUserName(email) {
@@ -254,54 +255,68 @@ function processHistory(history) {
return email;
}
- if (history) {
-// console.log("processHistory: history = " + history.toSource());
- return ;
- }
+// MC $$$ NOT DONE YET
+// // Sometimes the history will stack several changes together,
+// // and we'll want to append the data from the Nth item to the
+// // div created in N-1
+// if (history) {
+// history.bugs.forEach(function (historyBug) {
+// historyBug.history.forEach(function (historyItem) {
+// processHistoryItem(comments, historyItem);
+// });
+// });
+// }
-// var historyItems = iframe.contentDocument.querySelectorAll('#bugzilla-body
-// tr');
-// var cmtTimes = document.querySelectorAll('.bz_comment_time');
+// handleEmptyCollapsedBoxes(document);
- // Sometimes the history will stack several changes together,
- // and we'll want to append the data from the Nth item to the
- // div created in N-1
- var i=0, j=0, flagsFound;
- if (history) {
- Array.forEach(history, function (item) {
- processHistoryItem(cmtTimes, item);
- });
- }
+ // // Set the latest flag links if necessary
+ // for (var flagName in flagOccurrences) {
+ // flags[flagName].innerHTML = '<a href="#' + flagOccurrences[flagName] + '">'
+ // + flags[flagName].innerHTML + '</a>';
+ // }
- handleEmptyCollapsedBoxes(document);
+ // AttachmentFlagHandler.setupLinks(document);
+ // END OF load event handler
-// // Set the latest flag links if necessary
-// for (var flagName in flagOccurrences) {
-// flags[flagName].innerHTML = '<a href="#' + flagOccurrences[flagName] + '">'
-// + flags[flagName].innerHTML + '</a>';
-// }
+}
-// AttachmentFlagHandler.setupLinks(document);
- // END OF load event handler
+/*
+ {
+ "when": "2011-04-13T17:07:04Z",
+ "who": "mcepl@redhat.com",
+ "changes": [
+ {
+ "removed": "",
+ "added": "needinfo?(suckfish@ihug.co.nz)",
+ "field_name": "flagtypes.name",
+ "field": "Flags"
+ }
+ ]
+ },
+*/
+function displayCommentActions (comment, historyItem) {
+ if (historyItem.who == comment.who) {
+ }
}
+function processHistoryItem(objects, itemRaw) {
+ console.log("processHistoryItem: itemRaw = " + itemRaw.toSource());
-function processHistoryItem(commentTimes, itemRaw) {
- var item = itemRaw.querySelectorAll("td");
- if (!item[1])
- return;
+return ; // FIXME just to get rid of this unfinished and unanalyzed function
- var reachedEnd = false;
- for (; j < commentTimes.length; j++) {
- if (trimContent(item[1]) > trimContent(commentTimes[j])) {
- if (j < commentTimes.length - 1) {
- return;
- } else {
- reachedEnd = true;
- }
- }
+ var idx = itemRaw.when; // Given the mid-air protection we could assume
+ // history time to be unique per second.
+ if (idx in objects.attachment) {
+ displayAttachmentActions(objects.attachment[idx], itemRaw)
+ }
+ if (idx in objects.comment) {
+ displayCommentActions(objects.comment[idx], itemRaw)
+ }
+ // FIXME anything else?
+ displayRemainingActions(itemRaw);
+// =====================================================
var commentHead = commentTimes[j].parentNode;
var mainUser = commentHead.querySelector(".bz_comment_user a.email")
@@ -310,12 +325,17 @@ function processHistoryItem(commentTimes, itemRaw) {
var user = trimContent(item[0]);
var mainTime = trimContent(commentTimes[j]);
var time = trimContent(item[1]);
+
+// =====================================================================
+// $$$ FIXME the change is made by commenter? is that it?
var inline = (mainUser == user && time == mainTime);
+
+// §§§§ This is a function addToInlineHistory or something TODO
var currentDiv = document.createElement("div");
var userPrefix = '';
- if (inline) {
- // assume that the change was made by the same user
+ if (inline) {
+ // assume that the change was made by the same user // XXX? §§§
commentHead.appendChild(currentDiv);
currentDiv.setAttribute("class", "bztw_inlinehistory");
} else {
@@ -343,8 +363,12 @@ function processHistoryItem(commentTimes, itemRaw) {
htmlEncode(trimContent(item[1])) +"\">" +
getUserName(trimContent(item[0])) + "</a>: ";
}
+ // XXX END OF if (inline) CONSTRUCT
+
+// XXX flags
// check to see if this is a flag setting
- flagsFound = findFlag(item);
+ flagsFound = findFlag(item); // XXX findFlag call 2
+ // XXX Add <a name> around every flag comment
for (var idx = 0; idx < flagsFound.length; ++idx) {
var flag = flagsFound[idx];
flagOccurrences[flag] = 'flag' + flagCounter;
@@ -358,6 +382,7 @@ function processHistoryItem(commentTimes, itemRaw) {
++flagCounter;
}
+// XXX attachments
var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item);
if (inline) {
for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) {
@@ -366,9 +391,12 @@ function processHistoryItem(commentTimes, itemRaw) {
commentHead.insertBefore(anchor, commentHead.firstChild);
}
} else {
- userPrefix += attachmentFlagAnchors.map(function(name) '<a name="' + name + '"></a>').join("");
+ userPrefix += attachmentFlagAnchors.map(function(name) {
+ return '<a name="' + name + '"></a>';
+ }).join("");
}
+// XXX just adding/removing sometbody from CC list
var ccOnly = (trimContent(item[2]) == 'CC');
var ccPrefix = ccOnly ? '<span class="bztw_cc bztw_historyitem">' :
'<span class="bztw_historyitem">',
@@ -380,8 +408,10 @@ function processHistoryItem(commentTimes, itemRaw) {
formatTransition(trimContent(item[3]), trimContent(item[4]),
trimContent(item[2]), iframe.contentDocument);
+//
var nextItemsCount = item[0].rowSpan;
for (var k = 1; k < nextItemsCount; ++k) {
+ // XXX doing once more the same for non-first elements of the imte array.
ccOnly = false;
item = historyItems[++i].querySelectorAll("td")
ccPrefix = (trimContent(item[0]) == 'CC') ?
@@ -390,7 +420,7 @@ function processHistoryItem(commentTimes, itemRaw) {
// wasn't a CC and this one is
var prefix = ccSuffix + ccPrefix;
// check to see if this is a flag setting
- flagsFound = findFlag(item);
+ flagsFound = findFlag(item); // TODO findFlag call 1
for (var idx = 0; idx < flagsFound.length; ++idx) {
var flag = flagsFound[idx];
flagOccurrences[flag] = 'flag' + flagCounter;
@@ -412,9 +442,13 @@ function processHistoryItem(commentTimes, itemRaw) {
commentHead.insertBefore(anchor, commentHead.firstChild);
}
} else {
- prefix += attachmentFlagAnchors.map(function(name) '<a name="' + name + '"></a>').join("");
+ prefix += attachmentFlagAnchors.map(function(name) {
+ return '<a name="' + name + '"></a>';
+ }).join("");
}
+ // END OF THE SAME STUFF FOR NON-FIRST ITEMS
+
html += prefix +
transformType(trimContent(item[0]), trimContent(item[1]),
trimContent(item[2])) + ": " +
@@ -427,9 +461,9 @@ function processHistoryItem(commentTimes, itemRaw) {
} else {
html = '<div>' + html + '</div>';
}
+ // Add the new stuff to the place below the top of the comment div
currentDiv.innerHTML += html;
- break;
- }
+ // FIXME here used to be a break;
}
// ===================================================
@@ -741,8 +775,9 @@ AttachmentFlagHandlerCtor.prototype = {
return "attachflag" + this._counter;
},
_reParseRequest: /^(.+)([\?\-\+])(\((.+)@.+\))?$/,
+ _reParsePartToLinkify: /^\s*:\s+.+[\-\+\?](\s*\()?\s*$/,
_reParseInterestingFlag: /^(.+):\s+(.+)(([\-\+])|\?(\s+(\((.+)\)))?)$/,
- _reLinkifyInterestingFlag: /^(.+:\s+)(.+[\-\+\?])(\s+\(.+\))?$/,
+ _reLinkifyInterestingFlag: /^(\s*:\s+)(.+[\-\+\?])(\s*\(\s*)?$/,
_reAttachmentHref: /attachment\.cgi\?id=(\d+)$/i,
_reAttachmentFlagName: /^Attachment\s+#(\d+)\s+Flags$/i
};
@@ -975,7 +1010,6 @@ DataStoreCtor.prototype = {
_reAttachmentHref: /attachment\.cgi\?id=(\d+)$/i
};
-
function handleEmptyCollapsedBoxes() {
// first, try to get the display style of a CC field (any would do)
var historyBoxes = document.querySelectorAll(".bztw_history");