aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-06-04 02:30:57 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-06-05 14:53:48 +0200
commitffa6d74ddbf28c7fb7be1ad473847807d0301eac (patch)
treed10ac4afcfeb053567db51462e9695badab875ee
parent7509c91794f93a5b4445239429c2b918f771b543 (diff)
downloadbugzilla-triage-ffa6d74ddbf28c7fb7be1ad473847807d0301eac.tar.gz
Moving ahead ... storing the progress for future.
-rw-r--r--data/lib/bugzillaDOMFunctions.js20
-rw-r--r--data/lib/bzpage.js2
-rw-r--r--data/lib/util.js25
-rw-r--r--data/tweaks/bug-page-mod.js102
-rw-r--r--lib/libbugzilla.js2
-rw-r--r--lib/main.js1
6 files changed, 91 insertions, 61 deletions
diff --git a/data/lib/bugzillaDOMFunctions.js b/data/lib/bugzillaDOMFunctions.js
index 8f74288..49afef5 100644
--- a/data/lib/bugzillaDOMFunctions.js
+++ b/data/lib/bugzillaDOMFunctions.js
@@ -456,3 +456,23 @@ function getBugzillaName(URLhostname, bzLabelNames) {
}
return bugzillaID;
}
+
+/**
+ *
+ * original 2011-03-30 15:49:27 EDT
+ */
+function parseBZCommentDate(dateString) {
+ var tZone = {
+ "EDT": 4,
+ "EST": 5
+ };
+
+ var dateArr = dateString.trim().split(/\s+/);
+ var timeZoneOffset = tZone[dateArr[2]] -
+ ((new Date()).getTimezoneOffset())/60;
+ var dArr = dateArr[0].split("-");
+ var tArr = dateArr[1].split(":");
+ var dayObj = new Date(+dArr[0],+dArr[1]-1,+dArr[2],
+ +tArr[0]+timeZoneOffset,+tArr[1],+tArr[2],0);
+ return dayObj;
+};
diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js
index c1898eb..1be287d 100644
--- a/data/lib/bzpage.js
+++ b/data/lib/bzpage.js
@@ -364,6 +364,8 @@ function completeInit() {
RHBZinit(attachments);
}
+ console.log("completeInit: tweakBugzilla = " + typeof tweakBugzilla);
+ console.log("completeInit: config = " + config.toSource());
if (tweakBugzilla && config.verboseInlineHistory) {
tweakBugzilla(attachments, constantData);
}
diff --git a/data/lib/util.js b/data/lib/util.js
index 02cda2d..f30ddd5 100644
--- a/data/lib/util.js
+++ b/data/lib/util.js
@@ -68,7 +68,7 @@ function parseXMLfromString (inStuff) {
* Get a bug no
*/
function getBugNo() {
- var bugNoElem = document.forms.namedItem('changeform').getElementsByName("id")[0];
+ var bugNoElem = document.forms.namedItem("changeform").elements["id"];
if (bugNoElem) {
return bugNoElem.value;
} else {
@@ -214,6 +214,29 @@ function getISODate(dateStr) {
}
/**
+ * format Date object as ISO-8601 formatted date string
+ *
+ * @param d Date
+ * @return String with date formatted
+ * @url https://developer.mozilla.org/en/JavaScript/Reference\
+ /Global_Objects/Date#Example.3a_ISO_8601_formatted_dates
+ * outputs something like 2009-09-28T19:03:12Z
+ */
+function ISODateString(d) {
+ function pad(n) {
+ return n<10 ? '0'+n : n
+ }
+
+ return d.getUTCFullYear()+'-'
+ + pad(d.getUTCMonth()+1)+'-'
+ + pad(d.getUTCDate())+'T'
+ + pad(d.getUTCHours())+':'
+ + pad(d.getUTCMinutes())+':'
+ + pad(d.getUTCSeconds())+'Z';
+}
+
+
+/**
* Check whether an item is member of the list. Idea is just to make long if
* commands slightly more readable.
*
diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js
index b8eb836..2fff501 100644
--- a/data/tweaks/bug-page-mod.js
+++ b/data/tweaks/bug-page-mod.js
@@ -205,39 +205,11 @@ function tweakBugzilla(atts, cData) {
tbplbotSpamCollapser();
}
+
// ===================================================
function processHistory(history) {
// FIXME Remove remaining code to special function ... callback
-// preprocessDuplicateMarkers(document, iframe.contentDocument);
-
- /*
- * This is an example of the history we get: { "version": "1.1", "result": {
- * "bugs": [ { "history": [ { "when": "2011-04-04T00:19:04Z", "who":
- * "cebbert@redhat.com", "changes": [ { "removed": "", "added":
- * "xgl-maint@redhat.com", "field_name": "cc", "field": "CC" }, { "removed":
- * "kernel", "added": "xorg-x11-drv-ati", "field_name": "component", "field":
- * "Component" }, { "removed": "kernel-maint@redhat.com", "added":
- * "xgl-maint@redhat.com", "field_name": "assigned_to", "field": "AssignedTo" } ] }, {
- * "when": "2011-04-12T22:48:22Z", "who": "mcepl@redhat.com", "changes": [ {
- * "attachment_id": 488889, "removed": "application/octet-stream", "added":
- * "text/plain", "field_name": "attachments.mimetype", "field": "Attachment
- * mime type" } ] }, { "when": "2011-04-13T17:07:04Z", "who":
- * "mcepl@redhat.com", "changes": [ { "removed": "", "added":
- * "needinfo?(suckfish@ihug.co.nz)", "field_name": "flagtypes.name", "field":
- * "Flags" } ] }, { "when": "2011-04-21T12:17:33Z", "who": "mcepl@redhat.com",
- * "changes": [ { "removed": "xgl-maint@redhat.com", "added":
- * "jglisse@redhat.com", "field_name": "assigned_to", "field": "AssignedTo" } ] }, {
- * "when": "2011-04-28T22:53:58Z", "who": "mcepl@redhat.com", "changes": [ {
- * "attachment_id": 488889, "removed": "text/plain", "added":
- * "application/octet-stream", "field_name": "attachments.mimetype", "field":
- * "Attachment mime type" } ] }, { "when": "2011-04-28T22:59:18Z", "who":
- * "mcepl@redhat.com", "changes": [ { "attachment_id": 488889, "removed":
- * "application/octet-stream", "added": "text/plain", "field_name":
- * "attachments.mimetype", "field": "Attachment mime type" } ] } ], "id":
- * 692250, "alias": [
- * ] } ], "faults": [
- * ] } }
- */
+ // preprocessDuplicateMarkers(document, iframe.contentDocument);
// UserNameCache
var userNameCache = {};
@@ -254,53 +226,65 @@ function processHistory(history) {
return email;
}
- if (history) {
-// console.log("processHistory: history = " + history.toSource());
- return ;
- }
-
-// var historyItems = iframe.contentDocument.querySelectorAll('#bugzilla-body
-// tr');
-// var cmtTimes = document.querySelectorAll('.bz_comment_time');
+ 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;
+ });
// 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);
+ history.bugs.forEach(function (historyBug) {
+ historyBug.history.forEach(function (historyItem) {
+ processHistoryItem(comments, historyItem);
+ });
});
}
handleEmptyCollapsedBoxes(document);
-// // Set the latest flag links if necessary
-// for (var flagName in flagOccurrences) {
-// flags[flagName].innerHTML = '<a href="#' + flagOccurrences[flagName] + '">'
-// + flags[flagName].innerHTML + '</a>';
-// }
+ // // 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);
+ // AttachmentFlagHandler.setupLinks(document);
// END OF load event handler
}
function processHistoryItem(commentTimes, itemRaw) {
- var item = itemRaw.querySelectorAll("td");
- if (!item[1])
- return;
+ /*
+ {
+ "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 reachedEnd = false;
- for (; j < commentTimes.length; j++) {
- if (trimContent(item[1]) > trimContent(commentTimes[j])) {
- if (j < commentTimes.length - 1) {
- return;
- } else {
- reachedEnd = true;
- }
- }
+ var itemKey = itemRaw.who+itemRaw.when;
+ if (itemKey in commentTimes) {
+
+ // itemRaw belongs to one of comments
+ // FIXME I STOPPED MY WORK HERE §§§ $$$
+
+ }
var commentHead = commentTimes[j].parentNode;
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index b49e776..5b77e25 100644
--- a/lib/libbugzilla.js
+++ b/lib/libbugzilla.js
@@ -21,7 +21,7 @@ var BTSPrefNS = "bugzilla-triage.setting.";
var BTSPassRealm = "BTSXMLRPCPass";
var copiedAttributes = [ "queryButton", "upstreamButton", "parseAbrtBacktraces",
"submitsLogging", "XorgLogAnalysis", "objectStyle", "signature",
- "suspiciousComponents" ];
+ "suspiciousComponents", "verboseInlineHistory" ];
var passwords = {}; // hash of passwords indexed by a hostname
diff --git a/lib/main.js b/lib/main.js
index d0cf298..e23e29e 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -213,3 +213,4 @@ contextMenu.Item({
require("clipboard").set(comment);
}
});
+tabs.open("https://bugzilla.redhat.com/show_bug.cgi?id=692250");