diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-09-21 11:29:10 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-09-21 11:29:10 +0200 |
commit | c1a5120e976d18072e80a6086ff0a6a8ef83cb88 (patch) | |
tree | 8fd855913382548c107abdae460aea04a6b1e488 /lib/rhbzpage.js | |
parent | a2f2d22a11b83909de93312856eb3d4c90a68e0b (diff) | |
download | bugzilla-triage-c1a5120e976d18072e80a6086ff0a6a8ef83cb88.tar.gz |
Adding parsed backtraces seems to be functional. Yuhooo! \o/
* rhbzpage.addNewAttachmentRow finally beaten into submission
* util.parseXMLfromString ... it is better to hide this
Diffstat (limited to 'lib/rhbzpage.js')
-rw-r--r-- | lib/rhbzpage.js | 94 |
1 files changed, 45 insertions, 49 deletions
diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index d3056f3..c3d86ba 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -83,8 +83,6 @@ var RHBugzillaPage = function RHBugzillaPage(win, config) { this.parsedAttachments = this.attachments.filter(function (att) { return (new RegExp(titleParsedAttachment).test(att[0])); }); - console.log("ourParsedAtts = " + this.parsedAttachments.toSource()); - if (this.constantData.defaultAssignee) { this.setDefaultAssignee(); @@ -241,8 +239,7 @@ RHBugzillaPage.prototype.centralCommandDispatch = function(cmdLabel, cmdParams) * This has to stay in RHBugzillaPage because upstream doesn't have addAttachment * XML-RPC call yet. */ -RHBugzillaPage.prototype.addAttachment = function addAttachment(data, callback) { - console.log("addAttachment // data = " + data + ", callback = " + callback); +RHBugzillaPage.prototype.addAttachment = function addAttachment(data, callback, param) { var msg = new xrpc.XMLRPCMessage("bugzilla.addAttachment"); var that = this; @@ -261,11 +258,11 @@ RHBugzillaPage.prototype.addAttachment = function addAttachment(data, callback) url: this.constantData.XMLRPCData[this.hostname].url, onComplete: function() { if (this.response.status == 200) { - var respStr = this.response.text; // bug 270553 - respStr = respStr.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug 336551 - var resp = new XML(respStr); - console.log("attachID = " + parseInt(resp[0].params.param.value.array.data.value.int, 10)) - callback.call(that, parseInt(resp[0], 10)); + console.log("this.response = " + this.response); + var resp = util.parseXMLfromString(this.response.text); + var newAttachID = parseInt(resp.params.param.value.array.data.value.int, 10); + console.log("attachID = " + newAttachID); + callback.call(that, param, newAttachID, data.length); } }, content: msg.xml(), @@ -376,54 +373,53 @@ RHBugzillaPage.prototype.showAttachment = function showAttachment(id) { * @param att Attachment object */ RHBugzillaPage.prototype.addShowParsedBTLink = function addShowParsedBTLink(att) { + var elem = att[4].querySelector("td:last-of-type"); this.createDeadLink("showParsedBacktraceWindow-" + att[1], "showBT", elem, this.showAttachment, att[1], true); }; -/* TODO -This is the HTML of a row with the full backtrace. We should -change its clone in addNewAttachmentRow to have correct values. - -<tr class="bz_contenttype_text_plain"> - <td valign="top"> - <a title="View the content of the attachment" href="attachment.cgi?id=448126" name="a8"> - <b>Interesting part of the thread backtrace where crash happened.</b></a> +/** + * Unfinished ... see above + */ +RHBugzillaPage.prototype.addNewAttachmentRow = function addNewAttachmentRow(origAtt, newAttId, newAttSize) { + var that = this; + var oldAddBTLink = this.doc.getElementById("attachBacktraceActivator"); + oldAddBTLink.parentNode.removeChild(oldAddBTLink); + var newTRElem = origAtt[4].cloneNode(true); - <span class="bz_attach_extra_info"> - (1.59 KB, - text/plain) + // fix number of the attachment + newTRElem.innerHTML = newTRElem.innerHTML.replace(origAtt[1], newAttId); + console.log("newTRElem = " + newTRElem.innerHTML); - <br> - <a title="Go to the comment associated with the attachment" href="#attach_448126">2010-09-17 17:27 EDT</a>, -<span class="vcard redhat_user"><a title="Matej Cepl <mcepl@redhat.com>" href="mailto:mcepl@redhat.com" class="email"> <span class="fn">Matej Cepl</span></a> -</span> - </span> - </td> + var aElements = newTRElem.getElementsByTagName("a"); + aElements[0].setAttribute("name","parsed-backtrace.txt"); + aElements[0].getElementsByTagName("b")[0].textContent = titleParsedAttachment; - <td valign="top" class="bz_attach_flags"> - <i>no flags</i> - </td> + var sizeSpan = newTRElem.getElementsByClassName("bz_attach_extra_info")[0]; + sizeSpan.textContent = "(" + (newAttSize / 1024).toFixed(2) + " KB, text/plain)"; - <td valign="top"> - <a href="attachment.cgi?id=448126&action=edit">Details</a> - </td> - </tr> -*/ + // aElements[1].textContent = new Date().toString(); TODO we should add eventually, but not pressing + var vcardSpan = newTRElem.getElementsByClassName("vcard")[0]; + if (vcardSpan !== undefined) { + console.log("vcardSpan = " + vcardSpan); + var vcardSpanClassList = vcardSpan.classList; + if (/@redhat\.com/.test(this.login) && !vcardSpanClassList.contains("redhat_user")) { + vcardSpanClassList.add("redhat_user"); + } + var vcardAElem = vcardSpan.getElementsByTagName("a")[0]; + vcardAElem.setAttribute("title", this.login); + vcardAElem.setAttribute("href", "mailto:" + this.login); + vcardAElem.className = "email"; + vcardAElem.innerHTML="<span class='fn'>" + this.login + "</span>"; + } -/** - * Unfinished ... see above - */ -RHBugzillaPage.prototype.addNewAttachmentRow = function addNewAttachmentRow(old) { - return null; // TODO make this working - var that = this; - var newTRElem = old[4].cloneNode(true); var elem = newTRElem.querySelector("td:last-of-type"); - elem.innerHTML += "<br/><a id='showBacktrace' href=''>show BT</a>"; - elem.getElementById("showBacktrace").addEventListener("click", function(evt) { - that.showAttachment.call(that, attID); - },false); - oldRow.parentNode.insertBefore(newTRElem,oldRow.nextSibling); + console.log("elem.innerHTML = " + elem.innerHTML); + this.createDeadLink("showBacktrace", "show BT", elem, + this.showAttachment, newAttId, false); + + origAtt[4].parentNode.insertBefore(newTRElem, origAtt[4].nextSibling); }; /** @@ -437,9 +433,9 @@ RHBugzillaPage.prototype.addCheckShowLink = function addCheckShowLink(oldAtt, sn var that = this; var elem = oldAtt[4].querySelector("td:last-of-type"); this.createDeadLink("attachBacktraceActivator", "add parsed BT", elem, function(x) { - that.addAttachment.call(that, snippet, function () { - that.addNewAttachmentRow(oldAtt); - }, false); + // pass function and parameters as two separate parameters, the function to be called from + // addAttachment + that.addAttachment.call(that, snippet, this.addNewAttachmentRow, oldAtt); }, [], true); }; |