aboutsummaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-06-05 23:43:10 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-06-05 23:43:10 +0200
commit04ae9089f8a4d92764455491bbbc9cb805580c73 (patch)
treea7b232306d32cf4b8639f9dfa1497528090a8c61 /data
parent968a1a63f8e625994b40b7d2af2d22940285c63c (diff)
downloadbugzilla-triage-04ae9089f8a4d92764455491bbbc9cb805580c73.tar.gz
Next step in rewriting bug-page-mod.js.
Diffstat (limited to 'data')
-rw-r--r--data/tweaks/bug-page-mod.js330
1 files changed, 166 insertions, 164 deletions
diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js
index 2fff501..d1a4abd 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
@@ -226,27 +228,19 @@ function processHistory(history) {
return email;
}
- var comments = {};
- commentsWalker(function (comment) {
- var nameSpan = comment.querySelector(".bz_comment_user a.email");
- var timeSpan = comment.getElementsByClassName("bz_comment_time")[0];
- var commenter = parseMailto(nameSpan).trim();
- var newDate = parseBZCommentDate(timeSpan.textContent.trim());
- comments[commenter+ISODateString(newDate)] = timeSpan;
- });
+// 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);
+// });
+// });
+// }
- // 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);
- });
- });
- }
-
- handleEmptyCollapsedBoxes(document);
+// handleEmptyCollapsedBoxes(document);
// // Set the latest flag links if necessary
// for (var flagName in flagOccurrences) {
@@ -259,161 +253,169 @@ function processHistory(history) {
}
+/*
+ {
+ "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 processHistoryItem(commentTimes, itemRaw) {
- /*
- {
- "when": "2011-04-13T17:07:04Z",
- "who": "mcepl@redhat.com",
- "changes": [
- {
- "removed": "",
- "added": "needinfo?(suckfish@ihug.co.nz)",
- "field_name": "flagtypes.name",
- "field": "Flags"
- }
- ]
- },
- */
- console.log("processHistoryItem: commentTimes = " + commentTimes.toSource());
- console.log("processHistoryItem: itemRaw = " + itemRaw.toSource());
-
- var itemKey = itemRaw.who+itemRaw.when;
- if (itemKey in commentTimes) {
+function displayCommentActions (comment, historyItem) {
+ if (historyItem.who == comment.who) {
+ }
+}
- // itemRaw belongs to one of comments
- // FIXME I STOPPED MY WORK HERE §§§ $$$
+function processHistoryItem(objects, itemRaw) {
+ console.log("processHistoryItem: itemRaw = " + itemRaw.toSource());
+ 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 commentHead = commentTimes[j].parentNode;
- var mainUser = commentHead.querySelector(".bz_comment_user a.email")
- .href
- .substr(7);
- var user = trimContent(item[0]);
- var mainTime = trimContent(commentTimes[j]);
- var time = trimContent(item[1]);
- var inline = (mainUser == user && time == mainTime);
+// var mainUser = commentHead.querySelector(".bz_comment_user a.email")
+// .href
+// .substr(7);
+// var user = trimContent(item[0]);
+// var mainTime = trimContent(commentTimes[j]);
+// var time = trimContent(item[1]);
+// var inline = (mainUser == user && time == mainTime);
- var currentDiv = document.createElement("div");
- var userPrefix = '';
- if (inline) {
- // assume that the change was made by the same user
- commentHead.appendChild(currentDiv);
- currentDiv.setAttribute("class", "bztw_inlinehistory");
- } else {
- // the change was made by another user
- if (!reachedEnd) {
- var parentDiv = commentHead.parentNode;
- if (parentDiv.previousElementSibling &&
- parentDiv.previousElementSibling.className.indexOf("bztw_history") >= 0) {
- currentDiv = parentDiv.previousElementSibling;
- } else {
- parentDiv.parentNode.insertBefore(currentDiv, parentDiv);
- }
- } else {
- var parentDiv = commentHead.parentNode;
- if (parentDiv.nextElementSibling &&
- parentDiv.nextElementSibling.className.indexOf("bztw_history") >= 0) {
- currentDiv = parentDiv.nextElementSibling;
- } else {
- parentDiv.parentNode.appendChild(currentDiv);
- }
- }
- currentDiv.setAttribute("class", "bz_comment bztw_history");
- userPrefix += "<a class=\"email\" href=\"mailto:" +
- htmlEncode(trimContent(item[0])) + "\" title=\"" +
- htmlEncode(trimContent(item[1])) +"\">" +
- getUserName(trimContent(item[0])) + "</a>: ";
- }
- // check to see if this is a flag setting
- flagsFound = findFlag(item);
- for (var idx = 0; idx < flagsFound.length; ++idx) {
- var flag = flagsFound[idx];
- flagOccurrences[flag] = 'flag' + flagCounter;
- if (inline) {
- var anchor = document.createElement("a");
- anchor.setAttribute("name", "flag" + flagCounter);
- commentHead.insertBefore(anchor, commentHead.firstChild);
- } else {
- userPrefix += '<a name="flag' + flagCounter + '"></a>';
- }
- ++flagCounter;
- }
+// var currentDiv = document.createElement("div");
+// var userPrefix = '';
+// if (inline) {
+// // assume that the change was made by the same user
+// commentHead.appendChild(currentDiv);
+// currentDiv.setAttribute("class", "bztw_inlinehistory");
+// } else {
+// // the change was made by another user
+// if (!reachedEnd) {
+// var parentDiv = commentHead.parentNode;
+// if (parentDiv.previousElementSibling &&
+// parentDiv.previousElementSibling.className.indexOf("bztw_history") >= 0) {
+// currentDiv = parentDiv.previousElementSibling;
+// } else {
+// parentDiv.parentNode.insertBefore(currentDiv, parentDiv);
+// }
+// } else {
+// var parentDiv = commentHead.parentNode;
+// if (parentDiv.nextElementSibling &&
+// parentDiv.nextElementSibling.className.indexOf("bztw_history") >= 0) {
+// currentDiv = parentDiv.nextElementSibling;
+// } else {
+// parentDiv.parentNode.appendChild(currentDiv);
+// }
+// }
+// currentDiv.setAttribute("class", "bz_comment bztw_history");
+// userPrefix += "<a class=\"email\" href=\"mailto:" +
+// htmlEncode(trimContent(item[0])) + "\" title=\"" +
+// htmlEncode(trimContent(item[1])) +"\">" +
+// getUserName(trimContent(item[0])) + "</a>: ";
+// }
+// // check to see if this is a flag setting
+// flagsFound = findFlag(item);
+// for (var idx = 0; idx < flagsFound.length; ++idx) {
+// var flag = flagsFound[idx];
+// flagOccurrences[flag] = 'flag' + flagCounter;
+// if (inline) {
+// var anchor = document.createElement("a");
+// anchor.setAttribute("name", "flag" + flagCounter);
+// commentHead.insertBefore(anchor, commentHead.firstChild);
+// } else {
+// userPrefix += '<a name="flag' + flagCounter + '"></a>';
+// }
+// ++flagCounter;
+// }
- var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item);
- if (inline) {
- for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) {
- var anchor = document.createElement("a");
- anchor.setAttribute("name", attachmentFlagAnchors[idx]);
- commentHead.insertBefore(anchor, commentHead.firstChild);
- }
- } else {
- userPrefix += attachmentFlagAnchors.map(function(name) '<a name="' + name + '"></a>').join("");
- }
+// var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item);
+// if (inline) {
+// for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) {
+// var anchor = document.createElement("a");
+// anchor.setAttribute("name", attachmentFlagAnchors[idx]);
+// commentHead.insertBefore(anchor, commentHead.firstChild);
+// }
+// } else {
+// userPrefix += attachmentFlagAnchors.map(function(name) '<a name="' + name + '"></a>').join("");
+// }
- var ccOnly = (trimContent(item[2]) == 'CC');
- var ccPrefix = ccOnly ? '<span class="bztw_cc bztw_historyitem">' :
- '<span class="bztw_historyitem">',
- ccSuffix = '</span>';
- var html = userPrefix +
- ccPrefix +
- transformType(trimContent(item[2]), trimContent(item[3]),
- trimContent(item[4])) + ": " +
- formatTransition(trimContent(item[3]), trimContent(item[4]),
- trimContent(item[2]), iframe.contentDocument);
+// var ccOnly = (trimContent(item[2]) == 'CC');
+// var ccPrefix = ccOnly ? '<span class="bztw_cc bztw_historyitem">' :
+// '<span class="bztw_historyitem">',
+// ccSuffix = '</span>';
+// var html = userPrefix +
+// ccPrefix +
+// transformType(trimContent(item[2]), trimContent(item[3]),
+// trimContent(item[4])) + ": " +
+// formatTransition(trimContent(item[3]), trimContent(item[4]),
+// trimContent(item[2]), iframe.contentDocument);
- var nextItemsCount = item[0].rowSpan;
- for (var k = 1; k < nextItemsCount; ++k) {
- ccOnly = false;
- item = historyItems[++i].querySelectorAll("td")
- ccPrefix = (trimContent(item[0]) == 'CC') ?
- '<span class="bztw_cc bztw_historyitem">' : '<span class="bztw_historyitem">';
- // avoid showing a trailing semicolon if the previous entry
- // wasn't a CC and this one is
- var prefix = ccSuffix + ccPrefix;
- // check to see if this is a flag setting
- flagsFound = findFlag(item);
- for (var idx = 0; idx < flagsFound.length; ++idx) {
- var flag = flagsFound[idx];
- flagOccurrences[flag] = 'flag' + flagCounter;
- if (inline) {
- var anchor = document.createElement("a");
- anchor.setAttribute("name", "flag" + flagCounter);
- commentHead.insertBefore(anchor, commentHead.firstChild);
- } else {
- prefix += '<a name="flag' + flagCounter + '"></a>';
- }
- ++flagCounter;
- }
+// var nextItemsCount = item[0].rowSpan;
+// for (var k = 1; k < nextItemsCount; ++k) {
+// ccOnly = false;
+// item = historyItems[++i].querySelectorAll("td")
+// ccPrefix = (trimContent(item[0]) == 'CC') ?
+// '<span class="bztw_cc bztw_historyitem">' : '<span class="bztw_historyitem">';
+// // avoid showing a trailing semicolon if the previous entry
+// // wasn't a CC and this one is
+// var prefix = ccSuffix + ccPrefix;
+// // check to see if this is a flag setting
+// flagsFound = findFlag(item);
+// for (var idx = 0; idx < flagsFound.length; ++idx) {
+// var flag = flagsFound[idx];
+// flagOccurrences[flag] = 'flag' + flagCounter;
+// if (inline) {
+// var anchor = document.createElement("a");
+// anchor.setAttribute("name", "flag" + flagCounter);
+// commentHead.insertBefore(anchor, commentHead.firstChild);
+// } else {
+// prefix += '<a name="flag' + flagCounter + '"></a>';
+// }
+// ++flagCounter;
+// }
- var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item);
- if (inline) {
- for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) {
- var anchor = document.createElement("a");
- anchor.setAttribute("name", attachmentFlagAnchors[idx]);
- commentHead.insertBefore(anchor, commentHead.firstChild);
- }
- } else {
- prefix += attachmentFlagAnchors.map(function(name) '<a name="' + name + '"></a>').join("");
- }
+// var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item);
+// if (inline) {
+// for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) {
+// var anchor = document.createElement("a");
+// anchor.setAttribute("name", attachmentFlagAnchors[idx]);
+// commentHead.insertBefore(anchor, commentHead.firstChild);
+// }
+// } else {
+// prefix += attachmentFlagAnchors.map(function(name) '<a name="' + name + '"></a>').join("");
+// }
- html += prefix +
- transformType(trimContent(item[0]), trimContent(item[1]),
- trimContent(item[2])) + ": " +
- formatTransition(trimContent(item[1]), trimContent(item[2]),
- trimContent(item[0]), iframe.contentDocument);
- }
- html += ccSuffix;
- if (ccOnly) {
- html = '<div class="bztw_cc">' + html + '</div>';
- } else {
- html = '<div>' + html + '</div>';
- }
- currentDiv.innerHTML += html;
- break;
- }
+// html += prefix +
+// transformType(trimContent(item[0]), trimContent(item[1]),
+// trimContent(item[2])) + ": " +
+// formatTransition(trimContent(item[1]), trimContent(item[2]),
+// trimContent(item[0]), iframe.contentDocument);
+// }
+// html += ccSuffix;
+// if (ccOnly) {
+// html = '<div class="bztw_cc">' + html + '</div>';
+// } else {
+// html = '<div>' + html + '</div>';
+// }
+// currentDiv.innerHTML += html;
+// // FIXME here used to be a break;
+// }
}
// ===================================================