diff options
Diffstat (limited to 'data')
-rw-r--r-- | data/lib/bugzillaDOMFunctions.js | 66 | ||||
-rw-r--r-- | data/lib/jumpNextBug.js | 62 | ||||
-rw-r--r-- | data/lib/queries.js | 6 | ||||
-rw-r--r-- | data/rhlib/rhbzpage.js | 3 | ||||
-rw-r--r-- | data/tweaks/bug-page-mod.js | 37 |
5 files changed, 155 insertions, 19 deletions
diff --git a/data/lib/bugzillaDOMFunctions.js b/data/lib/bugzillaDOMFunctions.js index 98a2031..aedf131 100644 --- a/data/lib/bugzillaDOMFunctions.js +++ b/data/lib/bugzillaDOMFunctions.js @@ -283,6 +283,72 @@ function getProduct() { return null; } +function commentsWalker (fce) { + var comments = document.getElementById("comments"). + getElementsByClassName("bz_comment"); + Array.forEach(comments, function(item) { + fce(item); + }); +} + + +/** + * Parse the row with the attachment + * + * @param DOM + * element to be parsed + * @return array with string name of the attachment, integer its id number, + * string of MIME type, integer of size in kilobytes, and the whole + * element itself + * + * TODO error handling is missing ... it's bleee + */ +function parseAttachmentLine(inElem) { + var MIMEtype = ""; + var size = 0; + + // Skip over obsolete attachments + if (inElem.getElementsByClassName("bz_obsolete").length > 0) { + return ([]); + } + + // getting name of the attachment + var attName = 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]; + var 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(", "); + size = parseInt(stringArray[0], 10); + MIMEtype = stringArray[1].split(" ")[0]; + + return [ attName, id, MIMEtype, size, inElem ]; +} + + +/** + * collect the list of attachments in a structured format + * + * @return Array of arrays, one for each attachments; each record has string + * name of the attachment, integer its id number, string of MIME type, + * integer of size in kilobytes, and the whole element itself + */ +function getAttachments () { + var outAtts = []; + var atts = document.getElementById("attachment_table"). + getElementsByTagName("tr"); + for ( var i = 1, ii = atts.length - 1; i < ii; i++) { + outAtts.push(parseAttachmentLine(atts[i])); + } + return outAtts; +} + /** * Get login of the currently logged-in user. * diff --git a/data/lib/jumpNextBug.js b/data/lib/jumpNextBug.js index 68e719b..b777fe8 100644 --- a/data/lib/jumpNextBug.js +++ b/data/lib/jumpNextBug.js @@ -1,16 +1,54 @@ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; -var nextElement = {}; -var nextRE = new RegExp("Next"); -var aNavigElements = document.querySelectorAll("#bugzilla-body .navigation a"); -var filteredElements = Array.filter(aNavigElements, function(elem) { - return nextRE.test(elem.textContent); -}); -console.log("filteredElements.length = " + filteredElements.length); -if (filteredElements.length > 0) { - nextElement = filteredElements[0]; - nextElement.setAttribute("accesskey", "n"); - nextElement.innerHTML = "<u>N</u>ext"; -} +(function createRelationElements() { + var relation = {}; + var linkLabels = [ + "First", "Last", "Prev", "Next" + ]; + var labelToRelation = { + "First" : { + rel : "start" + }, + "Last" : { + rel : "last" + }, + "Prev" : { + rel : "prev" + }, + "Next" : { + rel : "next" + } + }; + + function createLinkRel(rel, href) { + var newLinkElement = document.createElement("link"); + newLinkElement.setAttribute("rel", rel); + newLinkElement.setAttribute("href", href); + document.getElementsByTagName("head")[0] + .appendChild(newLinkElement); + } + + var aNavigElements = document + .querySelectorAll("#bugzilla-body .navigation a"); + Array.forEach(aNavigElements, function(elem) { + var labelText = elem.textContent.trim(); + if (isInList(labelText, linkLabels)) { + labelToRelation[labelText].href = elem + .getAttribute("href"); + } + ; + }); + console.myDebug("labelToRelation = " + + labelToRelation.toSource()); + + for ( var key in labelToRelation) { + if (labelToRelation.hasOwnProperty(key)) { + relation = labelToRelation[key]; + if (relation.href) { + createLinkRel(relation.rel, relation.href); + } + } + } +})(); diff --git a/data/lib/queries.js b/data/lib/queries.js index 066991e..ccb2927 100644 --- a/data/lib/queries.js +++ b/data/lib/queries.js @@ -2,7 +2,7 @@ // http://www.opensource.org/licenses/mit-license.php "use strict"; -function getSelection() { +function getSel() { var text = ""; var selectionObject = window.getSelection(); if (selectionObject.rangeCount > 0) { @@ -64,7 +64,7 @@ function queryInNewTab(text, component, product, equivComps) { * function this.queryInNewTab, and run it. */ function queryForSelection() { - var text = getSelection(); + var text = getSel(); if (!text) { self.postMessage(new Message("GetClipboard", "queryLocal")); } @@ -107,7 +107,7 @@ function queryUpstream(qUpBug) { alert("We don't have constantData.queryUpstreamBug set up!"); return null; } - var text = getSelection(); + var text = getSel(); if (!text) { self .postMessage(new Message("GetClipboard", "queryUpstream")); diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index 99d36a2..cbd8665 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -15,6 +15,7 @@ var RawhideColor = new Color(0, 119, 0); // or "green", or RGB 0, 119, 0, or // HSL // 120, 0, 23 var RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20 +var titleParsedAttachment = "Part of the thread where crash happened"; // [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf" var logAnalyzeLogic = { @@ -102,7 +103,7 @@ function closeSomeRelease() { // "Fixed in Version" textbox // otherwise -> NEXTRELEASE selectOption("bug_status", "CLOSED"); - var text = getSelection(); + var text = getSel(); var resolution = ""; if (text.length > 0) { diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js index ece4f36..f5d154e 100644 --- a/data/tweaks/bug-page-mod.js +++ b/data/tweaks/bug-page-mod.js @@ -207,12 +207,39 @@ function tweakBugzilla(things, 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": [ + * ] } } + */ // UserNameCache var userNameCache = {}; function getUserName(email) { @@ -364,7 +391,9 @@ return ; // FIXME just to get rid of this unfinished and unanalyzed function 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 @@ -413,7 +442,9 @@ return ; // FIXME just to get rid of this unfinished and unanalyzed function 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 |