aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data/tweaks/bug-page-mod.js259
-rw-r--r--lib/libbugzilla.js1
-rw-r--r--package.json2
3 files changed, 139 insertions, 123 deletions
diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js
index d1a4abd..ece4f36 100644
--- a/data/tweaks/bug-page-mod.js
+++ b/data/tweaks/bug-page-mod.js
@@ -276,6 +276,8 @@ function displayCommentActions (comment, historyItem) {
function processHistoryItem(objects, itemRaw) {
console.log("processHistoryItem: itemRaw = " + itemRaw.toSource());
+return ; // FIXME just to get rid of this unfinished and unanalyzed function
+
var idx = itemRaw.when; // Given the mid-air protection we could assume
// history time to be unique per second.
if (idx in objects.attachment) {
@@ -288,134 +290,149 @@ function processHistoryItem(objects, itemRaw) {
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 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;
-// }
+// =====================================================================
+// $$$ FIXME the change is made by commenter? is that it?
+ var inline = (mainUser == user && time == mainTime);
-// 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);
+// §§§§ 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 // XXX? §§§
+ 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>: ";
+ }
+ // XXX END OF if (inline) CONSTRUCT
-// 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;
-// }
+// XXX flags
+ // check to see if this is a flag setting
+ 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;
+ 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 {
-// prefix += attachmentFlagAnchors.map(function(name) '<a name="' + name + '"></a>').join("");
-// }
+// XXX attachments
+ 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("");
+ }
-// 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;
-// }
+// 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">',
+ 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) {
+ // 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') ?
+ '<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); // TODO findFlag call 1
+ 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("");
+ }
+
+ // END OF THE SAME STUFF FOR NON-FIRST ITEMS
+
+ 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>';
+ }
+ // Add the new stuff to the place below the top of the comment div
+ currentDiv.innerHTML += html;
+ // FIXME here used to be a break;
}
// ===================================================
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index 2f0bebb..2dc1dc5 100644
--- a/lib/libbugzilla.js
+++ b/lib/libbugzilla.js
@@ -11,7 +11,6 @@ var passUtils = require("passwords");
var Request = require("request").Request;
var selfMod = require("self");
var urlMod = require("url");
-var dataUtils = require("utils/data");
var xrpc = require("xmlrpc");
var panelMod = require("panel");
diff --git a/package.json b/package.json
index 4668b7b..8127917 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"description": "Additional buttons and other function helping in the triage on bugzilla",
"author": "Matej Cepl (http://matej.ceplovi.cz)",
"license": "MIT/X11 (http://opensource.org/licenses/mit-license.php) and MPL",
- "version": "1.4",
+ "version": "1.4.2",
"contributors": [
"Ehsan Akhgari (http://ehsanakhgari.org/) <ehsan@mozilla.com>",
"Johnathan Nightingale (http://johnath.com) <johnath@mozilla.com>",