diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-07-19 14:30:39 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-07-19 15:22:49 +0200 |
commit | d75f36db36c442ae9621dc128fbd916c25d5735f (patch) | |
tree | c9ed3fcd6f86d28a9434b95e5060f3f64be17917 /data | |
parent | e06a2341056cabd82fae8527d30a9ec97b24dc10 (diff) | |
parent | 4ef203c974e889b74e4064ee04eddc55ba7b8c08 (diff) | |
download | bugzilla-triage-d75f36db36c442ae9621dc128fbd916c25d5735f.tar.gz |
Merge branch 'bugzillatweaks' into next.
This is a horribly botched branch merged.
Conflicts:
chip-data/chipNames.json
data/lib/bugzillaDOMFunctions.js
data/lib/bzpage.js
data/lib/jumpNextBug.js
data/lib/otherButtons.js
data/lib/queries.js
data/lib/util.js
data/rhlib/addAttachmentRow.js
data/rhlib/fixingAttMIME.js
data/rhlib/rhbzpage.js
data/tweaks/bug-page-mod.js
data/tweaks/viewSource.js
lib/libbugzilla.js
lib/main.js
package.json
Diffstat (limited to 'data')
-rw-r--r-- | data/lib/bugzillaDOMFunctions.js | 47 | ||||
-rw-r--r-- | data/lib/bzpage.js | 45 | ||||
-rw-r--r-- | data/lib/collectingMetadata.js | 188 | ||||
-rw-r--r-- | data/lib/otherButtons.js | 31 | ||||
-rw-r--r-- | data/lib/util.js | 33 | ||||
-rw-r--r-- | data/rhlib/addAttachmentRow.js | 1 | ||||
-rw-r--r-- | data/rhlib/fixingAttMIME.js | 6 | ||||
-rw-r--r-- | data/rhlib/rhbzpage.js | 159 | ||||
-rw-r--r-- | data/tweaks/bug-page-mod.js | 134 | ||||
-rw-r--r-- | data/tweaks/viewSource.js | 8 |
10 files changed, 437 insertions, 215 deletions
diff --git a/data/lib/bugzillaDOMFunctions.js b/data/lib/bugzillaDOMFunctions.js index 8f74288..aedf131 100644 --- a/data/lib/bugzillaDOMFunctions.js +++ b/data/lib/bugzillaDOMFunctions.js @@ -147,6 +147,32 @@ function getDefaultBugzillaMaintainer (component) { } /** + * dd + * + * @return Element with the href attribute containng the information + */ +function getOptionTableCell(tableId, label) { + var cleanLabelRE = new RegExp("^\\s*([^.:]*):?\\s*$"); + label = label.trim().replace(cleanLabelRE,"$1").toLowerCase(); + + var rows = document.getElementById(tableId).getElementsByTagName("tr"); + var ourLine = Array.filter(rows, function(row) { + var curLabelElems = row.getElementsByTagName("td"); + if (curLabelElems.length > 0) { + var curLabel = curLabelElems[0].textContent.toLowerCase(); + curLabel = curLabel.replace(cleanLabelRE,"$1"); + return (curLabel === label); // maybe this could be a RE match instead + } + }); + + if (ourLine.length > 0) { + return ourLine[0].getElementsByTagName("td")[1]. + getElementsByTagName("a")[0]; + } + return null; +} + +/** * Generic function to add new button to the page. Actually copies new button * from the old one (in order to have the same look-and-feel, etc. * @@ -408,7 +434,6 @@ function killNodes(doc, target, remove) { // removing its members. for(var i = 0, ii = victimElements.length; i < ii; i++) { elem = victimElements[i]; - console.myDebug("Killing element " + elem[0]); try { elem[1].parentNode.removeChild(elem[1]); } @@ -456,3 +481,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..4401792 100644 --- a/data/lib/bzpage.js +++ b/data/lib/bzpage.js @@ -329,43 +329,25 @@ function setConfigurationButton () { } /** - * dd - * - * @return Element with the href attribute containng the information - */ -function getOptionTableCell(tableId, label) { - var cleanLabelRE = new RegExp("^\\s*([^.:]*):?\\s*$"); - label = label.trim().replace(cleanLabelRE,"$1").toLowerCase(); - - var rows = document.getElementById(tableId).getElementsByTagName("tr"); - var ourLine = Array.filter(rows, function(row) { - var curLabel = row.getElementsByTagName("td")[0].textContent.toLowerCase(); - curLabel = curLabel.replace(cleanLabelRE,"$1"); - return (curLabel === label); // maybe this could be a RE match instead - }); - - if (ourLine.length > 0) { - return ourLine[0].getElementsByTagName("td")[1]. - getElementsByTagName("a")[0]; - } - return null; -} - - -/** * Complete startup, mainly run alternate inits for non-standard BZ with proper * arguments * */ function completeInit() { - var attachments = getAttachments(); + // FIXME: add flags, and priority or others bits. + var things = { + attachments: new AttachList(document), + comments: new CommentList(document) + }; if (RHBZinit) { - RHBZinit(attachments); + RHBZinit(things); } + things.comments.colorComments(); + if (tweakBugzilla && config.verboseInlineHistory) { - tweakBugzilla(attachments, constantData); + tweakBugzilla(things, constantData); } } @@ -398,6 +380,13 @@ function startup() { } } + // Prepare for adding external bugs + var a0Elements = document.getElementsByName("a0"); + if (a0Elements.length > 0) { + var extBugsHeadline = a0Elements[a0Elements.length - 1]; + extBugsHeadline.setAttribute("id", "external_bugs_headline"); + } + // TODO Probably could be ignored ... used only once on line 973 of // rhbzpage.js // if (parseAbrtBacktraces && this.RE.Abrt.test(getSummary())) { @@ -408,8 +397,6 @@ function startup() { setConfigurationButton(); submitHandlerInstalled = false; - checkComments(); - self.postMessage(new Message("GetInstalledPackages", { location: window.location.href, login: getLogin() diff --git a/data/lib/collectingMetadata.js b/data/lib/collectingMetadata.js new file mode 100644 index 0000000..6fe57a4 --- /dev/null +++ b/data/lib/collectingMetadata.js @@ -0,0 +1,188 @@ +// Released under the MIT/X11 license +// http://www.opensource.org/licenses/mit-license.php +"use strict"; + +function Comment(comment) { + var nameSpan = comment.querySelector(".bz_comment_user a.email"); + var timeSpan = comment.getElementsByClassName("bz_comment_time")[0]; + + this.author = parseMailto(nameSpan).trim(); + this.element = comment; + this.date = parseBZCommentDate(timeSpan.textContent.trim()); + this.timeSpan = timeSpan; +} + +Comment.prototype.getText = function getText() { + return this.element.getElementsByTagName("pre")[0].textContent.trim(); +} + +function CommentList(doc) { + var commentElems = document.getElementById("comments"). + getElementsByClassName("bz_comment"); + var comments = {}; + Array.forEach(commentElems, function(item) { + var com = new Comment(item); + if (com.element) { + comments[ISODateString(com.date)] = com; + } + }); + this.comments = comments; +} + +/** + * Set background color of all comments made by reporter in ReporterColor color + * + */ +CommentList.prototype.colorComments = function colorComments() { + var reporter = getReporter(); + var com = null; + for (var idx in this.comments) { + com = this.comments[idx]; + if (com.author === reporter) { + com.element.style.backgroundColor = ReporterColor.toString(); + } + } +} + +CommentList.prototype.getAllCommentsText = function getAllCommentsText() { + var outStr = ""; + for (var idx in this.comments) { + outStr += this.comments[idx].getText() + "\n"; + } + return outStr; +} +// ----------------------------------------------------------- + +/** + * Parse the row with the attachment and create new Attachment object + * + * @param DOM + * element to be parsed + * + * TODO error handling is missing ... it's bleee + * + * [ attName, id, MIMEtype, size, inElem ]; + */ +function Attachment(inElem) { + // Skip over obsolete attachments + if (inElem.getElementsByClassName("bz_obsolete").length > 0) { + return; // FIXME how NOT to create an object? + } + + // getting name of the attachment + this.name = inElem.getElementsByTagName("b")[0].textContent.trim(); + + // TODO probably could use url.URL object + var aHrefsArr = inElem.getElementsByTagName("a"); + var aHref = Array.filter(aHrefsArr, function(x) { + return x.textContent.trim() === "Details"; + })[0]; + this.id = parseURL(aHref.getAttribute("href")).params.id; + + // getting MIME type and size + var stringArray = inElem.getElementsByClassName("bz_attach_extra_info")[0]. + textContent.replace(/[\n ()]+/g, " ").trim().split(", "); + this.size = parseInt(stringArray[0], 10); + this.mimeType = stringArray[1].split(" ")[0]; + this.element = inElem; +}; + +Attachment.prototype.isBadMIME = function isBadMIME() { + var badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ]; + return isInList(this.mimeType, badMIMEArray); +}; + +Attachment.prototype.checkXorgLink = function checkXorgLink() { + var elemS = this.element.getElementsByTagName("td"); + var elem = elemS[elemS.length - 1]; + createDeadLink("xorgLogAnalyzeLink", "check", elem, + analyzeXorgLog, [this.id, "AnalyzeXorgLogBacktrace"], "br"); +}; + +Attachment.prototype.isParsed = function isParsed() { + var titleParsedAttachment = "Part of the thread where crash happened"; + return (new RegExp(titleParsedAttachment).test(this.name)); +}; + +// ---------------------------------------------------------------------------- +function AttachList(doc) { + this.attachments = []; + var attach = {}; + var attElements = doc.getElementById("attachment_table"). + getElementsByTagName("tr"); + // FIXME change into list of objects and both comments and + // attachments (and something else?) should be properties of one + // huge object + for ( var i = 1, ii = attElements.length - 1; i < ii; i++) { + attach = new Attachment(attElements[i]); + if (attach.id) { + this.attachments.push(attach); + } + } +} + +AttachList.prototype.getBadAttachments = function getBadAttachments() { + return this.attachments.filter(function(att) { + return (att.isBadMIME()); + }); +} + +/** + * Add a link opening selected lines of Xorg.0.log + */ +AttachList.prototype.addCheckXorgLogLink = function addCheckXorgLogLink() { + if (config.XorgLogAnalysis) { + this.getXorgList(). + forEach(function (att) { + att.checkXorgLink(); + }); + } +} + +/** + * Make it sailent that the some attachments with bad MIME type are present + * + * @param atts + * Array of attachments subarrays + * @return none + */ +AttachList.prototype.markBadAttachments = function markBadAttachments() { + if (!constantData.passwordState.passAvailable) { + console.log("markBadAttachments : No password, no XML-RPC calls; sorry"); + return null; + } + + var badAttachments = this.getBadAttachments(); + + if (badAttachments.length > 0) { + var titleElement = document. + getElementsByClassName("bz_alias_short_desc_container")[0]; + titleElement.style.backgroundColor = "olive"; + + createDeadLink("fixAllButton", "Fix all", titleElement, function() { + Array.forEach(badAttachments, function(x) { + fixAttachById(x.id, constantData.XMLRPCData[window.location.hostname].url); + }); + }, [], false, null, "f"); + badAttachments.forEach(function(x, i, a) { + addTextLink(x, constantData.XMLRPCData[window.location.hostname].url); + }); + } +}; + +AttachList.prototype.getParsedAttachments = function getParsedAttachments() { + return this.attachments.filter(function (att) { + return (att.isParsed()); + }); +}; + +AttachList.prototype.getXorgList = function getXorgList() { + return this.attachments.filter(function (value) { + // Xorg.0.log must be text, otherwise we cannot parse it + return (/[xX].*log/.test(value.name) && /text/.test(value.mimeType)); + }); +}; + +AttachList.prototype.forEach = function forEach(fce) { + this.attachments.forEach(fce); +}; diff --git a/data/lib/otherButtons.js b/data/lib/otherButtons.js index 31a4dd8..6935b8e 100644 --- a/data/lib/otherButtons.js +++ b/data/lib/otherButtons.js @@ -3,30 +3,6 @@ "use strict"; /** - * Set background color of all comments made by reporter in ReporterColor color - * - */ -function checkComments() { - var reporter = getReporter(); - commentsWalker(function(x) { - var email = parseMailto(x.getElementsByClassName("vcard")[0] - .getElementsByTagName("a")[0]); - if (email.indexOf(reporter) != -1) { - x.style.backgroundColor = ReporterColor.toString(); - } - }); -} - -function collectComments() { - var outStr = ""; - commentsWalker(function(x) { - outStr += x.getElementsByTagName("pre")[0].textContent - + "\n"; - }); - return outStr.trim(); -} - -/** * Find default assignee based on the current component * * @return String what would be a default assignee if we haven't set it up. @@ -119,7 +95,7 @@ function addingEmbelishments(logList) { && (!FillMagicDoneRE.test(getSummary())) && (maintCCAddr == "xgl-maint@redhat.com")) { // Add find chip magic button - fillInChipMagic(logList[0][1]); + fillInChipMagic(logList[0].id); } // Add links for creating new bug in the same product @@ -138,10 +114,13 @@ function addingEmbelishments(logList) { * String with the IsueTracker numbers * @return none */ -function setBranding(xLogAtts) { +function setBranding(things) { var brandColor = {}; var TriagedColor = {}; + var atts = things.attachments; + var xLogAtts = atts.getXorgList(); + var ITbutton = document.getElementById("cf_issuetracker"); var its = ITbutton ? ITbutton.value.trim() : ""; diff --git a/data/lib/util.js b/data/lib/util.js index 92b9436..b128d48 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -68,8 +68,12 @@ function parseXMLfromString (inStuff) { * Get a bug no */ function getBugNo() { - console.log("bugNo = " + document.getElementsByName("id")[0].value); - return document.getElementsByName("id")[0].value; + var bugNoElem = document.forms.namedItem("changeform").elements["id"]; + if (bugNoElem) { + return bugNoElem.value; + } else { + return null; + } } /** @@ -210,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. * @@ -220,7 +247,7 @@ function getISODate(dateStr) { * @return position of the string in the list, or -1 if none found. */ function isInList(mbr, list) { - if (!list) { + if (!Array.isArray(list)) { return false; } return (list.indexOf(mbr) !== -1); diff --git a/data/rhlib/addAttachmentRow.js b/data/rhlib/addAttachmentRow.js index 63babcd..c8724e3 100644 --- a/data/rhlib/addAttachmentRow.js +++ b/data/rhlib/addAttachmentRow.js @@ -6,7 +6,6 @@ function addAttachmentCallback(resp) { var newAttachID = parseInt( resp.params.param.value.array.data.value.int, 10); - console.log("attachID = " + newAttachID); // FIXME callback.call(param, newAttachID, data.length); } diff --git a/data/rhlib/fixingAttMIME.js b/data/rhlib/fixingAttMIME.js index 9834cfa..f61ddbd 100644 --- a/data/rhlib/fixingAttMIME.js +++ b/data/rhlib/fixingAttMIME.js @@ -78,11 +78,11 @@ function fixAttachById(id, XMLRPCURL, type, email) { * <TR> DOM jQuery element with a bad attachment * @return none */ -function addTextLink(row, xmlRpcUrl) { - var elemS = row[4].getElementsByTagName("td"); +function addTextLink(att, xmlRpcUrl) { + var elemS = att.element.getElementsByTagName("td"); var elem = elemS[elemS.length - 1]; createDeadLink("addFix2TextLink", "text", elem, fixAttachById, [ - row[1], xmlRpcUrl + att.id, xmlRpcUrl ], "br"); } diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index f74556c..cbd8665 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -55,7 +55,7 @@ var ProfessionalProducts = [ // END OF CONSTANTS var btSnippet = null; - +var localThings = null; // I don't like it, but we need to store it somewhere for now function RHOnMessageHandler(msg, nextHandlerList) { switch (msg.cmd) { @@ -143,7 +143,10 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) { case "chipMagic": fillInWhiteBoard(cmdParams); break; - // If we don't have it here, call superclass method + case "addExternalBugID": + addExternalBug(); + break; + // If we don't have it here, call superclass method default: if (MozCentralCommandDispatch) { MozCentralCommandDispatch(cmdLabel, cmdParams); @@ -155,76 +158,35 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) { } } -/** - * Make it sailent that the some attachments with bad MIME type are present - * - * @param atts - * Array of attachments subarrays - * @return none - */ -function markBadAttachments(atts) { - var badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ]; - if (!constantData.passwordState.passAvailable) { - console.myDebug("markBadAttachments : No password, no XML-RPC calls; sorry"); - return null; - } - - var badAttachments = atts.filter(function(att) { - return (isInList(att[2], badMIMEArray)); - }); - - if (badAttachments.length > 0) { - var titleElement = document. - getElementsByClassName("bz_alias_short_desc_container")[0]; - titleElement.style.backgroundColor = "olive"; - - createDeadLink("fixAllButton", "Fix all", titleElement, function() { - Array.forEach(badAttachments, function(x) { - fixAttachById(x[1], constantData.XMLRPCData[window.location.hostname].url); - }); - }, [], false, null, "f"); - badAttachments.forEach(function(x, i, a) { - addTextLink(x, constantData.XMLRPCData[window.location.hostname].url); - }); - } -} +/* === Bugzilla functions === */ /** * Open a tab in the upstream bugzilla to create a new bug * * @return none */ -function sendBugUpstream() { - var admitMsg = "(originally filed as " + window.location.href + ")\n\n"; - var urlStr = filterByRegexp(constantData.newUpstreamBug, getComponent()); - if (!urlStr) { - return null; +function sendBugUpstream(thgs) { + if (thgs) { + localThings = thgs; + return; } + if (localThings) { + var admitMsg = "(originally filed as " + window.location.href + ")\n\n"; + var urlStr = filterByRegexp(constantData.newUpstreamBug, getComponent()); + if (!urlStr) { + return null; + } - self.postMessage(new Message("OpenBugUpstream", { - url: urlStr, - subject: document.getElementById("short_desc_nonedit_display"). - textContent.trim(), - comment: admitMsg + collectComments() - })); -} - -/** - * Add a link opening selected lines of Xorg.0.log - * - * @return none - */ -function addCheckXorgLogLink(attList) { - if (config.XorgLogAnalysis) { - attList.forEach(function (row) { - var elemS = row[4].getElementsByTagName("td"); - var elem = elemS[elemS.length - 1]; - createDeadLink("xorgLogAnalyzeLink", "check", elem, - analyzeXorgLog, [row[1], "AnalyzeXorgLogBacktrace"], "br"); - }); + self.postMessage(new Message("OpenBugUpstream", { + url: urlStr, + subject: document.getElementById("short_desc_nonedit_display"). + textContent.trim(), + comment: admitMsg + localThings.comments.getAllCommentsText() + })); } } + /** * Given line to be parsed, find out which chipset it is and fill in the * whiteboard @@ -267,7 +229,6 @@ function fillInChipMagic(XlogID) { function chipsetMagic (interestingLineArr) { // parse Xorg.0.log var cardStr = ""; - console.myDebug("interestingLineArr[1] = " + interestingLineArr[1]); if (interestingLineArr.length >0) { var interestingArray = interestingLineArr[0]; @@ -374,15 +335,13 @@ function findInterestingLine(wholeLog, backMsg) { } /** - * Add information about the upstream bug upstream, and closing it. + * Add an external bug reference from the input box * - * @param evt - * Event which called this handler - * @return none + * @return String with the external bug URL or null */ -function addClosingUpstream() { +function addExternalBug() { var refs = document.getElementById("external_bugs_table") - .getElementsByTagName("tr"); + .getElementsByTagName("tr"); // that's a bad id, if there is a one. :) var inputBox = document.getElementById("inputbox"); @@ -390,8 +349,8 @@ function addClosingUpstream() { var wholeURL = ""; // Fix missing ID on the external_id SELECT - document.getElementsByName("external_id")[0].setAttribute("id", - "external_id"); + document.getElementsByName("external_id")[0]. + setAttribute("id", "external_id"); if (inputBox.value.match(/^http.*/)) { wholeURL = inputBox.value; @@ -405,29 +364,40 @@ function addClosingUpstream() { var bugzillaName = getBugzillaName(parseURL(wholeURL).host, constantData.bugzillaLabelNames); selectOptionByLabel("external_id", bugzillaName); + return wholeURL; } else if (!isNaN(inputBox.value)) { - externalBugID = parseInt(inputBox.value, 10); - var bugzillaHostname = document.getElementById("external_id").value; - wholeURL = bugzillaHostname+"show_bug.cgi?id="+externalBugID; + return document.getElementById("external_id").value + + "show_bug.cgi?id=" + parseInt(inputBox.value, 10); } else { // no inputBox.value -- maybe there is an external bug from // the previous commit? + return null; } +} - // It is not good to close bug as UPSTREAM, if there is no reference - // to the upstream bug. - if ((externalBugID > 0) || (refs.length > 2)) { - var msgStr = constantData.commentStrings.sentUpstreamString; - msgStr = msgStr.replace("§§§", wholeURL); - centralCommandDispatch("comment",msgStr); - centralCommandDispatch("status", "CLOSED"); - centralCommandDispatch("resolution", "UPSTREAM"); - } - else { +/** + * Add information about the upstream bug upstream, and closing it. + * + * @param evt + * Event which called this handler + * @return none + */ +function addClosingUpstream() { + + var newBugURL = addExternalBug(); + + if (!newBugURL) { console.myDebug("No external bug specified among the External References!"); + return null; } + + var msgStr = constantData.commentStrings.sentUpstreamString; + msgStr = msgStr.replace("§§§", newBugURL); + centralCommandDispatch("comment",msgStr); + centralCommandDispatch("status", "CLOSED"); + centralCommandDispatch("resolution", "UPSTREAM"); } /** @@ -469,21 +439,21 @@ function parseBacktrace (ret) { return ""; } -function RHBZinit(attachments) { +function RHBZinit(things) { // inheritance ... call superobject's constructor var AbrtRE = new RegExp("^\\s*\\[abrt\\]"); var btSnippet = ""; + sendBugUpstream(things); // FIXME this is not a real call, + // just initializing static variable var chipMagicInterestingLine = ""; // getBadAttachments var XorgLogAttList = []; var XorgLogAttListIndex = 0; - markBadAttachments(attachments); + things.attachments.markBadAttachments(); - var parsedAttachments = attachments.filter(function (att) { - return (new RegExp(titleParsedAttachment).test(att[0])); - }); + var parsedAttachments = things.attachments.getParsedAttachments(); if (constantData.defaultAssignee) { setDefaultAssignee(); @@ -505,21 +475,14 @@ function RHBZinit(attachments) { // Dig out backtrace protection against double-firing? btSnippet = ""; - var parseAbrtBacktraces = config.parseAbrtBacktraces; - if (parseAbrtBacktraces && AbrtRE.test(getSummary())) { + if (config.parseAbrtBacktraces && AbrtRE.test(getSummary())) { pasteBacktraceInComments(parsedAttachments); } - // Find out Xorg.0.log attachment URL - XorgLogAttList = attachments.filter(function (value) { - // Xorg.0.log must be text, otherwise we cannot parse it - return (/[xX].*log/.test(value[0]) && /text/.test(value[2])); - }); - // Just add a link to every Xorg.0.log link analyzing it. - addCheckXorgLogLink(XorgLogAttList); + things.attachments.addCheckXorgLogLink(); - setBranding(XorgLogAttList); + setBranding(things); // Don't allow to submit a page which would change the bug to 0xFFFF component document.forms.namedItem("changeform").addEventListener( 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"); diff --git a/data/tweaks/viewSource.js b/data/tweaks/viewSource.js index 81e6735..2415531 100644 --- a/data/tweaks/viewSource.js +++ b/data/tweaks/viewSource.js @@ -39,12 +39,12 @@ var reAttachmentType = /,\s+([^ )]*)[;)]/; function viewAttachmentSource(attachments) { attachments.forEach(function(att) { - if (att.length < 1) { + if (!att.id) { return; } - var typeName = att[2]; - var elem = att[4]; - var id = att[1]; + var typeName = att.mimeType; + var elem = att.element; + var id = att.id; var attachHref = elem.getAttribute("href"); if (typeName == "application/java-archive" |