aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data/XMLRPCdata.json9
-rw-r--r--data/lib/addAttachmentRow.js32
-rw-r--r--data/lib/bzpage.js23
-rw-r--r--data/lib/util.js4
-rw-r--r--data/rhlib/fixingAttMIME.js11
-rw-r--r--data/tweaks/bug-page-mod.js1576
-rw-r--r--lib/libbugzilla.js87
-rw-r--r--lib/main.js11
8 files changed, 986 insertions, 767 deletions
diff --git a/data/XMLRPCdata.json b/data/XMLRPCdata.json
index 4dab662..e378f22 100644
--- a/data/XMLRPCdata.json
+++ b/data/XMLRPCdata.json
@@ -1,8 +1,11 @@
{
"bugzilla.redhat.com": {
- "url": "https://bugzilla.redhat.com/xmlrpc.cgi"
+ "url": "https://bugzilla.redhat.com/xmlrpc.cgi"
+ },
+ "bugzilla.mozilla.org": {
+ "url": "https://bugzilla.mozilla.org/xmlrpc.cgi"
},
"bz-web2-test.devel.redhat.com": {
- "url": "https://bz-web2-test.devel.redhat.com/xmlrpc.cgi"
+ "url": "https://bz-web2-test.devel.redhat.com/xmlrpc.cgi"
}
-} \ No newline at end of file
+}
diff --git a/data/lib/addAttachmentRow.js b/data/lib/addAttachmentRow.js
index a2b67ee..3bee73a 100644
--- a/data/lib/addAttachmentRow.js
+++ b/data/lib/addAttachmentRow.js
@@ -2,6 +2,7 @@
// http://www.opensource.org/licenses/mit-license.php
"use strict";
+// FIXME resp is JSON, not XML anymore
function addAttachmentCallback(resp) {
var newAttachID = parseInt(
resp.params.param.value.array.data.value.int, 10);
@@ -13,6 +14,25 @@ function addAttachmentCallback(resp) {
*
* This has to stay in RHBugzillaPage because upstream doesn't have
* addAttachment XML-RPC call yet.
+ *
+ Params: $params = {
+ id => '<bug_id>', # ID of the bug report
+ comment => "<Attachment Comment>", # OPTIONAL Text string containing comment to add.
+ description => "<Attachment Description>", # REQUIRED Text Description of the attachment.
+ isprivate => <Private Attachment ON/OFF 1/0>, # OPTIONAL Whether the Attachment
+ will be private # Default: false
+ filename => "<Attachment Filename>", REQUIRED The name of the file to attach to the bug report.
+ obsoletes => [List of attach_id's to obsolete], OPTIONAL List if attachment ids that are
+ obsoleted by this new attachment.
+ ispatch => <Patch Attachment True/False 1/0>, OPTIONAL Whether the attachment is a Patch
+ or not, if not provided the it will be considered NON Patch attachment.
+ contenttype => "<Attachment Content Type>", OPTIONAL If the attachment is patch
+ REQUIRED If the attachment is not a patch
+ If the attachment is patch then contenttype will always be text/plain
+ data => "<Encoded String of the Attachment Data>", REQUIRED It is a base64
+ encoded string of the actual attachment data.
+ nomail => 0, OPTIONAL Flag that is either 1 or 0 if you want email
+ to be send ot not for this change }
*/
function addAttachment(data, callback, param) {
var params = [];
@@ -23,18 +43,18 @@ function addAttachment(data, callback, param) {
return null;
}
- params.push(getBugNo());
- params.push({
+ var params = {
+ id: getBugNo(),
description : titleParsedAttachment,
filename : "parsed-backtrace.txt",
contenttype : "text/plain",
data : window.btoa(data),
nomail : true
- });
+ };
- self.postMessage(new Message("MakeXMLRPCall", {
- url : constantData.XMLRPCData[window.location.hostname].url,
- login : getLogin(),
+ self.postMessage(new Message("MakeJSONRPCCall", {
+ url : constantData.XMLRPCData[window.location.hostname].url.
+ replace("xmlrpc.cgi","jsonrpc.cgi"),
method : "bugzilla.addAttachment",
params : params,
callRPC : "AddAttachmentCallback"
diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js
index 9e65794..02c8e3c 100644
--- a/data/lib/bzpage.js
+++ b/data/lib/bzpage.js
@@ -43,8 +43,8 @@ onMessage = function onMessage(msg) {
case "Unhandled":
break;
default:
- if (RHOnMessageHandler) {
- RHOnMessageHandler(msg);
+ if (TweakOnMessageHandler) {
+ TweakOnMessageHandler(msg, RHOnMessageHandler);
}
else {
console.error("Error: unknown RPC call " + msg.toSource());
@@ -55,7 +55,7 @@ onMessage = function onMessage(msg) {
/**
* @param cmd
* Object with all commands to be executed
- *
+ *
* PROBLEM: according to
* https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference\
* /Statements/for...in there is no guaranteed order of execution of commands
@@ -73,7 +73,7 @@ function executeCommand(cmdObj) {
/**
* Actual execution function
- *
+ *
* @param cmdLabel
* String with the name of the command to be executed
* @param cmdParams
@@ -184,7 +184,7 @@ function centralCommandDispatch (cmdLabel, cmdParams) {
/**
* Change assignee of the bug
- *
+ *
* @param newAssignee
* String with the email address of new assigneeAElement or 'default'
* if the component's default assignee should be used. Value null
@@ -228,7 +228,7 @@ function changeAssignee (newAssignee) {
/**
* Adds new option to the 'comment_action' scroll down box
- *
+ *
* @param pkg
* String package name
* @param cmd
@@ -312,8 +312,13 @@ function generateButtons (pkgs, kNodes) {
// constantData etc.
// are finally defined and available.
if (RHBZinit) {
+ console.log("call RHBZinit!");
RHBZinit();
}
+
+ if (tweakBugzilla) {
+ tweakBugzilla(document, constantData);
+ }
}
function setConfigurationButton () {
@@ -333,7 +338,7 @@ function setConfigurationButton () {
/**
* dd
- *
+ *
* @return Element with the href attribute containng the information
*/
function getOptionTableCell(tableId, label) {
@@ -356,13 +361,13 @@ function getOptionTableCell(tableId, label) {
/**
* 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) {
diff --git a/data/lib/util.js b/data/lib/util.js
index 77e7bfa..abf8824 100644
--- a/data/lib/util.js
+++ b/data/lib/util.js
@@ -68,8 +68,8 @@ function parseXMLfromString (inStuff) {
* Get a bug no
*/
function getBugNo() {
- console.log("bugNo = " + document.forms.namedItem('changeform').getElementsByName("id")[0].value);
- return document.forms.namedItem('changeform').getElementsByName("id")[0].value;
+ console.log("bugNo = " + document.getElementsByName("id")[0].value);
+ return document.getElementsByName("id")[0].value;
}
/**
diff --git a/data/rhlib/fixingAttMIME.js b/data/rhlib/fixingAttMIME.js
index 365cfae..c2adde4 100644
--- a/data/rhlib/fixingAttMIME.js
+++ b/data/rhlib/fixingAttMIME.js
@@ -45,8 +45,6 @@ function XMLRPCcallback() {
*
*/
function fixAttachById(id, XMLRPCURL, type, email) {
- var params = [];
-
if (type === undefined) {
type = "text/plain";
}
@@ -57,15 +55,14 @@ function fixAttachById(id, XMLRPCURL, type, email) {
// https://bugzilla.redhat.com/\
// docs/en/html/api/extensions/compat_xmlrpc/code/webservice.html
// test on https://bugzilla.redhat.com/show_bug.cgi?id=485145
- params.push({
+ var params = {
'attach_id' : id,
'mime_type' : type,
'nomail' : !email
- });
+ };
- self.postMessage(new Message("MakeXMLRPCall", {
- url : XMLRPCURL,
- login : getLogin(),
+ self.postMessage(new Message("MakeJSONRPCall", {
+ url : XMLRPCURL.replace("xmlrpc.cgi","jsonrpc.cgi"),
method : "bugzilla.updateAttachMimeType",
params : params,
callRPC : "FixAttachmentMIMECallback"
diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js
index a405edb..9d80abc 100644
--- a/data/tweaks/bug-page-mod.js
+++ b/data/tweaks/bug-page-mod.js
@@ -1,487 +1,647 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+/*******************************************************************************
+ * ***** BEGIN LICENSE BLOCK Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
+ * 1.1 (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
*
* The Original Code is Bugzilla Tweaks.
*
- * The Initial Developer of the Original Code is Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
+ * The Initial Developer of the Original Code is Mozilla Foundation. Portions
+ * created by the Initial Developer are Copyright (C) 2010 the Initial
+ * Developer. All Rights Reserved.
*
- * Contributor(s):
- * Johnathan Nightingale <johnath@mozilla.com>
- * Ehsan Akhgari <ehsan@mozilla.com>
+ * Contributor(s): Johnathan Nightingale <johnath@mozilla.com> Ehsan Akhgari
+ * <ehsan@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
+ * either the GNU General Public License Version 2 or later (the "GPL"), or the
+ * GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which
+ * case the provisions of the GPL or the LGPL are applicable instead of those
+ * above. If you wish to allow use of your version of this file only under the
+ * terms of either the GPL or the LGPL, and not to allow others to use your
+ * version of this file under the terms of the MPL, indicate your decision by
+ * deleting the provisions above and replace them with the notice and other
+ * provisions required by the GPL or the LGPL. If you do not delete the
+ * provisions above, a recipient may use your version of this file under the
+ * terms of any one of the MPL, the GPL or the LGPL.
*
- * ***** END LICENSE BLOCK ***** */
+ * ***** END LICENSE BLOCK *****
+ */
-function tweakBugzilla(d) {
- // run on both bugzilla.m.o and bugzilla-stage-tip.m.o
- // if (!onBugzillaPage(d.URL))
- // return;
+function TweakOnMessageHandler(msg, nextHandler) {
+ switch (msg.cmd) {
+ case "Unhandled":
+ break;
+ case "returnedHistory":
+ processHistory(msg.data);
+ break;
+ default:
+ if (nextHandler) {
+ nextHandler(msg);
+ }
+ else {
+ console.error("Error: unknown RPC call " + msg.toSource());
+ }
+ break;
+ }
+}
- // Put the quicksearch text in the quicksearch boxes
- quicksearchHandler(d);
+/**
+ * generate XML-RPC call to collect complete history of the bug
+ * @param XMLRPCURL URL of the XML-RPC gateway on the particular bugzilla
+ * @returns nothing
+ *
+ * As part of the message is name of the signal "returnedHistory"
+ */
+function collectHistory(rpcURL) {
+ // https://bugzilla.redhat.com/docs/en/html/api/Bugzilla\
+ // /WebService/Bug.html#Bug_Information
+ var bugId = getBugNo();
+ self.postMessage(new Message("MakeJSONRPCall", {
+ url : rpcURL.replace("xmlrpc.cgi","jsonrpc.cgi"),
+ login : getLogin(),
+ method : "Bug.history",
+ params : { "ids": [ bugId ] },
+ callRPC : "returnedHistory"
+ }));
+}
- if (!d.getElementById("comments")) // don't process the mid-air collision
- // pages
- return;
+function tweakBugzilla(d, cData) {
+ // run on both bugzilla.m.o and bugzilla-stage-tip.m.o
+ // if (!onBugzillaPage(d.URL))
+ // return;
- // Make the comment box bigger
- var commentBox = d.querySelector("#comment");
- if (commentBox)
- commentBox.rows=20;
+ // Put the quicksearch text in the quicksearch boxes
+ quicksearchHandler(d);
- addNewLinks(d);
+ if (!d.getElementById("comments")) // don't process the mid-air collision
+ // pages
+ return;
- attachmentDiffLinkify(d);
+ // Make the comment box bigger
+ var commentBox = d.querySelector("#comment");
+ if (commentBox)
+ commentBox.rows=20;
- viewAttachmentSource(d);
+ addNewLinks(d);
- // Mark up history along right hand edge
- var historyLink = d.querySelector("link[title='Bug Activity']");
- if (!historyLink)
- return;
+ attachmentDiffLinkify(d);
- // Add our own style for bugzilla-tweaks
- var style = d.createElement("style");
- style.setAttribute("type", "text/css");
- style.appendChild(d.createTextNode(
- ".bztw_history { border: none; font-weight: normal; width: 58em; margin-left: 5em; }" +
- ".bztw_inlinehistory { font-weight: normal; width: 56em; }" +
- ".bztw_history .old, .bztw_inlinehistory .old { text-decoration: line-through; }" +
- ".bztw_history .sep:before { content: \" \"; }" +
- ".bztw_unconfirmed { font-style: italic; }" +
- "tr.bz_tr_obsolete.bztw_plusflag { display: table-row !important; }" +
- '.bztw_historyitem + .bztw_historyitem:before { content: "; "; }'
- ));
- d.getElementsByTagName("head")[0].appendChild(style);
- style = d.createElement("style");
- style.setAttribute("type", "text/css");
- style.id = "bztw_cc";
- style.appendChild(d.createTextNode(
- ".bztw_cc { display: none; }" +
- '.bztw_historyitem.bztw_cc + .bztw_historyitem:before { content: ""; }' +
- '.bztw_historyitem:not([class~="bztw_cc"]) ~ .bztw_historyitem.bztw_cc + .bztw_historyitem:before { content: "; "; }'
- ));
- d.getElementsByTagName("head")[0].appendChild(style);
-
- var userNameCache = {};
- function getUserName(email) {
- if (email in userNameCache) {
- return userNameCache[email];
- }
- var emailLink = d.querySelectorAll("a.email");
- for (var i = 0; i < emailLink.length; ++i) {
- if (emailLink[i].href == "mailto:" + email) {
- return userNameCache[email] = htmlEncode(trimContent(emailLink[i]));
- }
- }
- return email;
- }
+ viewAttachmentSource(d);
- // collect the flag names
- var flagNames = [], flags = {}, flagOccurrences = {};
- var flagRows = d.querySelectorAll("#flags tr");
- for (var i = 0; i < flagRows.length; ++i) {
- var item = flagRows[i].querySelectorAll("td");
- if (!item[1])
- continue;
- var name = trimContent(item[1]).replace('\u2011', '-', 'g');
- flagNames.push(name);
- flags[name] = item[1];
+ // Mark up history along right hand edge
+ var historyLink = d.querySelector("link[title='Bug Activity']");
+ if (!historyLink)
+ return;
+
+ // Add our own style for bugzilla-tweaks
+ var style = d.createElement("style");
+ style.setAttribute("type", "text/css");
+ style.appendChild(d.createTextNode(
+ ".bztw_history { border: none; font-weight: normal; width: 58em; margin-left: 5em; }" +
+ ".bztw_inlinehistory { font-weight: normal; width: 56em; }" +
+ ".bztw_history .old, .bztw_inlinehistory .old { text-decoration: line-through; }" +
+ ".bztw_history .sep:before { content: \" \"; }" +
+ ".bztw_unconfirmed { font-style: italic; }" +
+ "tr.bz_tr_obsolete.bztw_plusflag { display: table-row !important; }" +
+ '.bztw_historyitem + .bztw_historyitem:before { content: "; "; }'
+ ));
+ d.getElementsByTagName("head")[0].appendChild(style);
+ style = d.createElement("style");
+ style.setAttribute("type", "text/css");
+ style.id = "bztw_cc";
+ style.appendChild(d.createTextNode(
+ ".bztw_cc { display: none; }" +
+ '.bztw_historyitem.bztw_cc + .bztw_historyitem:before { content: ""; }' +
+ '.bztw_historyitem:not([class~="bztw_cc"]) ~ .bztw_historyitem.bztw_cc + .bztw_historyitem:before { content: "; "; }'
+ ));
+ d.getElementsByTagName("head")[0].appendChild(style);
+
+ // UserNameCache
+ var userNameCache = {};
+ function getUserName(email) {
+ if (email in userNameCache) {
+ return userNameCache[email];
}
- flagRows = d.querySelectorAll(".field_label[id^=field_label_cf_]");
- for (var i = 0; i < flagRows.length; ++i) {
- var name = trimContent(flagRows[i]).replace(/\:$/, '')
- .replace('\u2011', '-', 'g');
- flagNames.push(name);
- flags[name] = flagRows[i];
+ var emailLink = d.querySelectorAll("a.email");
+ for (var i = 0; i < emailLink.length; ++i) {
+ if (emailLink[i].href == "mailto:" + email) {
+ return userNameCache[email] = htmlEncode(trimContent(emailLink[i]));
+ }
}
- var flagCounter = 1;
-
- // =================================================
- function findFlag(item) {
- function lookup(name) {
- name = name.replace('\u2011', '-', 'g');
- for (var i = 0; i < flagNames.length; ++i) {
- var quotedFlagName = flagNames[i].replace('.', '\\.', 'g')
- .replace('\u2011', '-', 'g');
- if ((new RegExp('^' + quotedFlagName)).test(name)) {
- return [flagNames[i]];
- }
- }
- return [];
- }
- var base = item[4] ? 2 : 0;
- // handle normal flags
- if (trimContent(item[base]) == 'Flag') {
- var result = [];
- var tmp = lookup(trimContent(item[base + 1]));
- if (tmp.length) {
- result.push(tmp[0]);
- }
- tmp = lookup(trimContent(item[base + 2]));
- if (tmp.length) {
- result.push(tmp[0]);
- }
- return result;
+ return email;
+ }
+
+ // collect the flag names
+ var flagNames = [], flags = {}, flagOccurrences = {};
+ var flagRows = d.querySelectorAll("#flags tr");
+ for (var i = 0; i < flagRows.length; ++i) {
+ var item = flagRows[i].querySelectorAll("td");
+ if (!item[1])
+ continue;
+ var name = trimContent(item[1]).replace('\u2011', '-', 'g');
+ flagNames.push(name);
+ flags[name] = item[1];
+ }
+ flagRows = d.querySelectorAll(".field_label[id^=field_label_cf_]");
+ for (var i = 0; i < flagRows.length; ++i) {
+ var name = trimContent(flagRows[i]).replace(/\:$/, '')
+ .replace('\u2011', '-', 'g');
+ flagNames.push(name);
+ flags[name] = flagRows[i];
+ }
+ var flagCounter = 1;
+
+ // =================================================
+ function findFlag(item) {
+ function lookup(name) {
+ name = name.replace('\u2011', '-', 'g');
+ for (var i = 0; i < flagNames.length; ++i) {
+ var quotedFlagName = flagNames[i].replace('.', '\\.', 'g')
+ .replace('\u2011', '-', 'g');
+ if ((new RegExp('^' + quotedFlagName)).test(name)) {
+ return [flagNames[i]];
}
- // handle special pseudo-flags
- return lookup(trimContent(item[base]));
+ }
+ return [];
+ }
+ var base = item[4] ? 2 : 0;
+ // handle normal flags
+ if (trimContent(item[base]) == 'Flag') {
+ var result = [];
+ var tmp = lookup(trimContent(item[base + 1]));
+ if (tmp.length) {
+ result.push(tmp[0]);
+ }
+ tmp = lookup(trimContent(item[base + 2]));
+ if (tmp.length) {
+ result.push(tmp[0]);
+ }
+ return result;
}
+ // handle special pseudo-flags
+ return lookup(trimContent(item[base]));
+ }
- var DataStore = new DataStoreCtor(d);
-
- var AttachmentFlagHandler = new AttachmentFlagHandlerCtor();
- AttachmentFlagHandler.determineInterestingFlags(d);
-
- var CheckinComment = new CheckinCommentCtor();
- CheckinComment.initialize(d, AttachmentFlagHandler._interestingFlags);
-
- var iframe = d.createElement('iframe');
- iframe.src = historyLink.href;
- iframe.style.display = "none";
- iframe.addEventListener("load", function() {
- preprocessDuplicateMarkers(d, iframe.contentDocument);
-
- var historyItems = iframe.contentDocument.querySelectorAll('#bugzilla-body tr');
- var commentTimes = d.querySelectorAll('.bz_comment_time');
-
- // 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;
- for (; i < historyItems.length; i++) {
- var item = historyItems[i].querySelectorAll("td");
- if (!item[1])
- continue;
-
- var reachedEnd = false;
- for (; j < commentTimes.length; j++) {
- if (trimContent(item[1]) > trimContent(commentTimes[j])) {
- if (j < commentTimes.length - 1) {
- continue;
- } else {
- reachedEnd = true;
- }
- }
+ var DataStore = new DataStoreCtor(d);
- 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 currentDiv = d.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 = d.createElement("a");
- anchor.setAttribute("name", "flag" + flagCounter);
- commentHead.insertBefore(anchor, commentHead.firstChild);
- } else {
- userPrefix += '<a name="flag' + flagCounter + '"></a>';
- }
- ++flagCounter;
- }
+ var AttachmentFlagHandler = new AttachmentFlagHandlerCtor();
+ AttachmentFlagHandler.determineInterestingFlags(d);
- var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item);
- if (inline) {
- for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) {
- var anchor = d.createElement("a");
- anchor.setAttribute("name", attachmentFlagAnchors[idx]);
- commentHead.insertBefore(anchor, commentHead.firstChild);
- }
- } else {
- userPrefix += attachmentFlagAnchors.map(function(name) '<a name="' + name + '"></a>').join("");
- }
+ var CheckinComment = new CheckinCommentCtor();
+ CheckinComment.initialize(d, AttachmentFlagHandler._interestingFlags);
- 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]), d, trimContent(item[3]),
- trimContent(item[4])) + ": " +
- formatTransition(trimContent(item[3]), trimContent(item[4]),
- trimContent(item[2]), d, iframe.contentDocument);
-
- 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 = d.createElement("a");
- anchor.setAttribute("name", "flag" + flagCounter);
- commentHead.insertBefore(anchor, commentHead.firstChild);
- } else {
- prefix += '<a name="flag' + flagCounter + '"></a>';
- }
- ++flagCounter;
- }
+ var XMLRPCUrl = cData.XMLRPCData[d.location.hostname].url;
+ collectHistory(XMLRPCUrl);
- var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item);
- if (inline) {
- for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) {
- var anchor = d.createElement("a");
- anchor.setAttribute("name", attachmentFlagAnchors[idx]);
- commentHead.insertBefore(anchor, commentHead.firstChild);
- }
- } else {
- prefix += attachmentFlagAnchors.map(function(name) '<a name="' + name + '"></a>').join("");
- }
+ tbplbotSpamCollapser(d);
+}
- html += prefix +
- transformType(trimContent(item[0]), d, trimContent(item[1]),
- trimContent(item[2])) + ": " +
- formatTransition(trimContent(item[1]), trimContent(item[2]),
- trimContent(item[0]), d, iframe.contentDocument);
- }
- html += ccSuffix;
- if (ccOnly) {
- html = '<div class="bztw_cc">' + html + '</div>';
- } else {
- html = '<div>' + html + '</div>';
- }
- currentDiv.innerHTML += html;
- break;
+// ===================================================
+function processHistory(history) {
+ // FIXME Remove remaining code to special function ... callback
+// preprocessDuplicateMarkers(d, 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": [
+
+ ]
+ }
+}
+ */
+
+ if (history) {
+// console.log("processHistory: history = " + history.toSource());
+ return ;
+ }
+
+// var historyItems = iframe.contentDocument.querySelectorAll('#bugzilla-body tr');
+// var cmtTimes = d.querySelectorAll('.bz_comment_time');
+
+ // 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);
+ });
+ }
+
+ 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>';
+// }
+
+// AttachmentFlagHandler.setupLinks(d);
+ // END OF load event handler
+
+}
+
+
+function processHistoryItem(commentTimes, itemRaw) {
+ var item = itemRaw.querySelectorAll("td");
+ if (!item[1])
+ return;
+
+ 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 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 currentDiv = d.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 = d.createElement("a");
+ anchor.setAttribute("name", "flag" + flagCounter);
+ commentHead.insertBefore(anchor, commentHead.firstChild);
+ } else {
+ userPrefix += '<a name="flag' + flagCounter + '"></a>';
+ }
+ ++flagCounter;
+ }
- handleEmptyCollapsedBoxes(d);
+ var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item);
+ if (inline) {
+ for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) {
+ var anchor = d.createElement("a");
+ anchor.setAttribute("name", attachmentFlagAnchors[idx]);
+ commentHead.insertBefore(anchor, commentHead.firstChild);
+ }
+ } else {
+ userPrefix += attachmentFlagAnchors.map(function(name) '<a name="' + name + '"></a>').join("");
+ }
- // Set the latest flag links if necessary
- for (var flagName in flagOccurrences) {
- flags[flagName].innerHTML = '<a href="#' + flagOccurrences[flagName] + '">'
- + flags[flagName].innerHTML + '</a>';
+ 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]), d, trimContent(item[3]),
+ trimContent(item[4])) + ": " +
+ formatTransition(trimContent(item[3]), trimContent(item[4]),
+ trimContent(item[2]), d, iframe.contentDocument);
+
+ 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 = d.createElement("a");
+ anchor.setAttribute("name", "flag" + flagCounter);
+ commentHead.insertBefore(anchor, commentHead.firstChild);
+ } else {
+ prefix += '<a name="flag' + flagCounter + '"></a>';
}
+ ++flagCounter;
+ }
- AttachmentFlagHandler.setupLinks(d);
- },true);
- d.body.appendChild(iframe);
+ var attachmentFlagAnchors = AttachmentFlagHandler.handleItem(user, item);
+ if (inline) {
+ for (var idx = 0; idx < attachmentFlagAnchors.length; ++idx) {
+ var anchor = d.createElement("a");
+ anchor.setAttribute("name", attachmentFlagAnchors[idx]);
+ commentHead.insertBefore(anchor, commentHead.firstChild);
+ }
+ } else {
+ prefix += attachmentFlagAnchors.map(function(name) '<a name="' + name + '"></a>').join("");
+ }
- tbplbotSpamCollapser(d);
+ html += prefix +
+ transformType(trimContent(item[0]), d, trimContent(item[1]),
+ trimContent(item[2])) + ": " +
+ formatTransition(trimContent(item[1]), trimContent(item[2]),
+ trimContent(item[0]), d, iframe.contentDocument);
+ }
+ html += ccSuffix;
+ if (ccOnly) {
+ html = '<div class="bztw_cc">' + html + '</div>';
+ } else {
+ html = '<div>' + html + '</div>';
+ }
+ currentDiv.innerHTML += html;
+ break;
+ }
}
// ===================================================
-
var TransformValues = {
linkifyURLs: function (str) {
- return str.replace(/((https?|ftp)\:\/\/[\S]+)/g, '<a href="$1">$1</a>');
+ return str.replace(/((https?|ftp)\:\/\/[\S]+)/g, '<a href="$1">$1</a>');
},
linkifyBugAndCommentNumbers: function (str) {
- return str.replace(/(bug )(\d+) (comment )(\d+)/gi, '<a href="show_bug.cgi?id=$2#c$4">$1\n$2 $3\n$4</a>');
+ return str.replace(/(bug )(\d+) (comment )(\d+)/gi, '<a href="show_bug.cgi?id=$2#c$4">$1\n$2 $3\n$4</a>');
},
linkifyCommentNumbers: function (str) {
- return str.replace(/(comment (\d+))/gi, '<a href="#c$2">$1</a>');
+ return str.replace(/(comment (\d+))/gi, '<a href="#c$2">$1</a>');
},
linkifyBugNumbers: function (str) {
- return str.replace(/(bug (\d+))/gi, '<a href="show_bug.cgi?id=$2">$1</a>');
+ return str.replace(/(bug (\d+))/gi, '<a href="show_bug.cgi?id=$2">$1</a>');
},
linkifyDependencies: function (str, type, doc, histDoc) {
- switch (type) {
- case "Blocks":
- case "Depends on":
- case "Duplicate":
- str = str.replace(/\d+/g, function(str) {
- var link = histDoc.querySelector("a[href='show_bug.cgi?id=" + str + "']");
- if (link) {
- var class_ = '';
- if (/bz_closed/i.test(link.className)) {
- class_ += 'bz_closed ';
- } else if (/bztw_unconfirmed/i.test(link.className)) {
- class_ += 'bztw_unconfirmed ';
- }
- var parent = link.parentNode;
- if (parent) {
- if (parent.tagName.toLowerCase() == "i") {
- class_ += 'bztw_unconfirmed ';
- }
- if (/bz_closed/i.test(parent.className)) {
- class_ += 'bz_closed ';
- }
- }
- str = applyClass(class_,
- '<a title="' + htmlEncode(link.title) + '" href="show_bug.cgi?id=' + htmlEncode(str) + '"' +
- (link.hasAttribute("name") ? (' name="' + htmlEncode(link.getAttribute("name")) + '"') : '') +
- '>' + htmlEncode(str) + '</a>');
- }
- return str;
- });
- }
- return str;
+ switch (type) {
+ case "Blocks":
+ case "Depends on":
+ case "Duplicate":
+ str = str.replace(/\d+/g, function(str) {
+ var link = histDoc.querySelector("a[href='show_bug.cgi?id=" + str + "']");
+ if (link) {
+ var class_ = '';
+ if (/bz_closed/i.test(link.className)) {
+ class_ += 'bz_closed ';
+ } else if (/bztw_unconfirmed/i.test(link.className)) {
+ class_ += 'bztw_unconfirmed ';
+ }
+ var parent = link.parentNode;
+ if (parent) {
+ if (parent.tagName.toLowerCase() == "i") {
+ class_ += 'bztw_unconfirmed ';
+ }
+ if (/bz_closed/i.test(parent.className)) {
+ class_ += 'bz_closed ';
+ }
+ }
+ str = applyClass(class_,
+ '<a title="' + htmlEncode(link.title) + '" href="show_bug.cgi?id=' + htmlEncode(str) + '"' +
+ (link.hasAttribute("name") ? (' name="' + htmlEncode(link.getAttribute("name")) + '"') : '') +
+ '>' + htmlEncode(str) + '</a>');
+ }
+ return str;
+ });
+ }
+ return str;
}
};
// ===============================================================================
function transform(str, type, doc, histDoc) {
- for (var funcname in TransformValues) {
- var func = TransformValues[funcname];
- str = func.call(null, str, type, doc, histDoc);
- }
- return str
+ for (var funcname in TransformValues) {
+ var func = TransformValues[funcname];
+ str = func.call(null, str, type, doc, histDoc);
+ }
+ return str
}
var TransformTypes = {
linkifyAttachments: function (str, doc) {
- return str.replace(/(Attachment #(\d+))/g, function (str, x, id) {
- var link = doc.querySelector("a[href='attachment.cgi?id=" + id + "']");
- if (link) {
- var class_ = '';
- if (/bz_obsolete/i.test(link.className)) {
- class_ += 'bz_obsolete ';
- }
- var parent = link.parentNode;
- if (parent && /bz_obsolete/i.test(parent.className)) {
- class_ += 'bz_obsolete ';
- }
- if (link.querySelector(".bz_obsolete")) {
- class_ += 'bz_obsolete ';
- }
- str = applyClass(class_,
- '<a title="' + htmlEncode(trimContent(link)) + '" href="attachment.cgi?id=' +
- htmlEncode(id) + '&action=edit">' + htmlEncode(str) + '</a>');
- }
- return str;
- });
+ return str.replace(/(Attachment #(\d+))/g, function (str, x, id) {
+ var link = doc.querySelector("a[href='attachment.cgi?id=" + id + "']");
+ if (link) {
+ var class_ = '';
+ if (/bz_obsolete/i.test(link.className)) {
+ class_ += 'bz_obsolete ';
+ }
+ var parent = link.parentNode;
+ if (parent && /bz_obsolete/i.test(parent.className)) {
+ class_ += 'bz_obsolete ';
+ }
+ if (link.querySelector(".bz_obsolete")) {
+ class_ += 'bz_obsolete ';
+ }
+ str = applyClass(class_,
+ '<a title="' + htmlEncode(trimContent(link)) + '" href="attachment.cgi?id=' +
+ htmlEncode(id) + '&action=edit">' + htmlEncode(str) + '</a>');
+ }
+ return str;
+ });
},
changeDependencyLinkTitles: function (str, doc, old, new_) {
- switch (str) {
- case "Blocks":
- case "Depends on":
- if (old.length && !new_.length) { // if the dependency was removed
- str = "No longer " + str[0].toLowerCase() + str.substr(1);
- }
- break;
+ switch (str) {
+ case "Blocks":
+ case "Depends on":
+ if (old.length && !new_.length) { // if the dependency was removed
+ str = "No longer " + str[0].toLowerCase() + str.substr(1);
}
- return str;
+ break;
+ }
+ return str;
}
};
// =======================================================================
function transformType(str, doc, old, new_) {
- for (var funcname in TransformTypes) {
- var func = TransformTypes[funcname];
- str = func.call(null, str, doc, old, new_);
- }
- return str;
+ for (var funcname in TransformTypes) {
+ var func = TransformTypes[funcname];
+ str = func.call(null, str, doc, old, new_);
+ }
+ return str;
}
// new is a keyword, which makes this function uglier than I'd like
function formatTransition(old, new_, type, doc, histDoc) {
- if (old.length) {
- old = transform(htmlEncode(old), type, doc, histDoc);
- var setOldStyle = true;
- switch (type) {
- case "Blocks":
- case "Depends on":
- setOldStyle = false;
- break;
- }
- if (setOldStyle) {
- old = '<span class="old">' + old + '</span>';
- }
- }
- if (new_.length) {
- new_ = '<span class="new">' + transform(htmlEncode(new_), type, doc, histDoc) + '</span>';
+ if (old.length) {
+ old = transform(htmlEncode(old), type, doc, histDoc);
+ var setOldStyle = true;
+ switch (type) {
+ case "Blocks":
+ case "Depends on":
+ setOldStyle = false;
+ break;
}
- var mid = '';
- if (old.length && new_.length) {
- mid = ' <span style="font-size: 150%;">&rArr;</span> ';
+ if (setOldStyle) {
+ old = '<span class="old">' + old + '</span>';
}
- return old + mid + new_;
+ }
+ if (new_.length) {
+ new_ = '<span class="new">' + transform(htmlEncode(new_), type, doc, histDoc) + '</span>';
+ }
+ var mid = '';
+ if (old.length && new_.length) {
+ mid = ' <span style="font-size: 150%;">&rArr;</span> ';
+ }
+ return old + mid + new_;
}
// =========================================================================
function trimContent(el) {
- return el.textContent.trim();
+ return el.textContent.trim();
}
function AttachmentFlag(flag) {
- for (var name in flag)
- this[name] = flag[name];
+ for (var name in flag)
+ this[name] = flag[name];
}
AttachmentFlag.prototype = {
equals: function(flag) {
- if (this.type != flag.type ||
- this.name != flag.name ||
- this.setter != flag.setter ||
- ("requestee" in this && !("requestee" in flag)) ||
- ("requestee" in flag && !("requestee" in this)))
- return false;
- return this.requestee == flag.requestee;
+ if (this.type != flag.type ||
+ this.name != flag.name ||
+ this.setter != flag.setter ||
+ ("requestee" in this && !("requestee" in flag)) ||
+ ("requestee" in flag && !("requestee" in this)))
+ return false;
+ return this.requestee == flag.requestee;
}
};
@@ -537,155 +697,155 @@ function quicksearchHandler(doc) {
}
function AttachmentFlagHandlerCtor() {
- this._db = {};
- this._interestingFlags = {};
+ this._db = {};
+ this._interestingFlags = {};
}
AttachmentFlagHandlerCtor.prototype = {
determineInterestingFlags: function (doc) {
- var table = doc.getElementById("attachment_table");
- if (!table)
- return;
- var rows = table.querySelectorAll("tr");
- for (var i = 0; i < rows.length; ++i) {
- var item = rows[i].querySelectorAll("td");
- if (item.length != 3 ||
- item[1].className.indexOf("bz_attach_flags") < 0 ||
- trimContent(item[1]) == "no flags")
- continue;
- // get the ID of the attachment
- var link = item[0].querySelector("a");
- if (!link)
- continue;
- var match = this._reAttachmentHref.exec(link.href);
+ var table = doc.getElementById("attachment_table");
+ if (!table)
+ return;
+ var rows = table.querySelectorAll("tr");
+ for (var i = 0; i < rows.length; ++i) {
+ var item = rows[i].querySelectorAll("td");
+ if (item.length != 3 ||
+ item[1].className.indexOf("bz_attach_flags") < 0 ||
+ trimContent(item[1]) == "no flags")
+ continue;
+ // get the ID of the attachment
+ var link = item[0].querySelector("a");
+ if (!link)
+ continue;
+ var match = this._reAttachmentHref.exec(link.href);
+ if (match) {
+ var attachmentID = match[1];
+ if (!(attachmentID in this._interestingFlags)) {
+ this._interestingFlags[attachmentID] = [];
+ }
+ for (var el = item[1].firstChild; el.nextSibling; el = el.nextSibling) {
+ if (el.nodeType != el.TEXT_NODE)
+ continue;
+ var text = trimContent(el).replace('\u2011', '-', 'g');
+ if (!text)
+ continue;
+ match = this._reParseInterestingFlag.exec(text);
if (match) {
- var attachmentID = match[1];
- if (!(attachmentID in this._interestingFlags)) {
- this._interestingFlags[attachmentID] = [];
+ var flag = {};
+ flag.setter = match[1];
+ flag.name = match[2];
+ if (match[4] == "+" || match[4] == "-") {
+ flag.type = match[4];
+ } else {
+ flag.type = "?";
+ if (match[7]) {
+ flag.requestee = match[7];
}
- for (var el = item[1].firstChild; el.nextSibling; el = el.nextSibling) {
- if (el.nodeType != el.TEXT_NODE)
- continue;
- var text = trimContent(el).replace('\u2011', '-', 'g');
- if (!text)
- continue;
- match = this._reParseInterestingFlag.exec(text);
- if (match) {
- var flag = {};
- flag.setter = match[1];
- flag.name = match[2];
- if (match[4] == "+" || match[4] == "-") {
- flag.type = match[4];
- } else {
- flag.type = "?";
- if (match[7]) {
- flag.requestee = match[7];
- }
- }
-
- // always show the obsolete attachments with a + flag
- if (flag.type == "+") {
- var parent = link.parentNode;
- while (parent) {
- if (parent.tagName.toLowerCase() == "tr") {
- if (/bz_tr_obsolete/i.test(parent.className)) {
- parent.className += " bztw_plusflag";
- }
- break;
- }
- parent = parent.parentNode;
- }
- }
-
- // try to put the flag name and type part in a span
- // which we will
- // use in setupLinks to inject links into.
- match = this._reLinkifyInterestingFlag.exec(text);
- if (match) {
- el.textContent = match[1];
- if (match[3]) {
- var textNode = doc.createTextNode(match[3]);
- el.parentNode.insertBefore(textNode, el.nextSibling);
- }
- var span = doc.createElement("span");
- span.textContent = match[2];
- el.parentNode.insertBefore(span, el.nextSibling);
+ }
- flag.placeholder = span;
- }
-
- this._interestingFlags[attachmentID].push(new AttachmentFlag(flag));
+ // always show the obsolete attachments with a + flag
+ if (flag.type == "+") {
+ var parent = link.parentNode;
+ while (parent) {
+ if (parent.tagName.toLowerCase() == "tr") {
+ if (/bz_tr_obsolete/i.test(parent.className)) {
+ parent.className += " bztw_plusflag";
}
+ break;
+ }
+ parent = parent.parentNode;
}
+ }
+
+ // try to put the flag name and type part in a span
+ // which we will
+ // use in setupLinks to inject links into.
+ match = this._reLinkifyInterestingFlag.exec(text);
+ if (match) {
+ el.textContent = match[1];
+ if (match[3]) {
+ var textNode = doc.createTextNode(match[3]);
+ el.parentNode.insertBefore(textNode, el.nextSibling);
+ }
+ var span = doc.createElement("span");
+ span.textContent = match[2];
+ el.parentNode.insertBefore(span, el.nextSibling);
+
+ flag.placeholder = span;
+ }
+
+ this._interestingFlags[attachmentID].push(new AttachmentFlag(flag));
}
+ }
}
+ }
},
handleItem: function (name, item) {
- var anchorsCreated = [];
- var base = item[4] ? 2 : 0;
- var what = trimContent(item[base]);
- var match = this._reAttachmentFlagName.exec(what);
- if (match) {
- var id = match[1];
- if (!(id in this._db)) {
- this._db[id] = [];
- }
- name = name.split('@')[0]; // convert the name to the fraction
- // before the @
- var added = this._parseData(name, trimContent(item[base + 2]));
- for (var i = 0; i < added.length; ++i) {
- var flag = added[i];
- if (!(id in this._interestingFlags))
- continue;
- for (var j = 0; j < this._interestingFlags[id].length; ++j) {
- if (flag.equals(this._interestingFlags[id][j])) {
- // found an interesting flag
- this._interestingFlags[id][j].anchor = this.anchorName;
- anchorsCreated.push(this.anchorName);
- this._counter++;
- break;
- }
- }
+ var anchorsCreated = [];
+ var base = item[4] ? 2 : 0;
+ var what = trimContent(item[base]);
+ var match = this._reAttachmentFlagName.exec(what);
+ if (match) {
+ var id = match[1];
+ if (!(id in this._db)) {
+ this._db[id] = [];
+ }
+ name = name.split('@')[0]; // convert the name to the fraction
+ // before the @
+ var added = this._parseData(name, trimContent(item[base + 2]));
+ for (var i = 0; i < added.length; ++i) {
+ var flag = added[i];
+ if (!(id in this._interestingFlags))
+ continue;
+ for (var j = 0; j < this._interestingFlags[id].length; ++j) {
+ if (flag.equals(this._interestingFlags[id][j])) {
+ // found an interesting flag
+ this._interestingFlags[id][j].anchor = this.anchorName;
+ anchorsCreated.push(this.anchorName);
+ this._counter++;
+ break;
}
+ }
}
- return anchorsCreated;
+ }
+ return anchorsCreated;
},
setupLinks: function (doc) {
- for (var id in this._interestingFlags) {
- for (var i = 0; i < this._interestingFlags[id].length; ++i) {
- var flag = this._interestingFlags[id][i];
- if ("placeholder" in flag &&
- "anchor" in flag) {
- var link = doc.createElement("a");
- link.href = "#" + flag.anchor;
- link.textContent = flag.placeholder.textContent;
- flag.placeholder.replaceChild(link, flag.placeholder.firstChild);
- }
- }
+ for (var id in this._interestingFlags) {
+ for (var i = 0; i < this._interestingFlags[id].length; ++i) {
+ var flag = this._interestingFlags[id][i];
+ if ("placeholder" in flag &&
+ "anchor" in flag) {
+ var link = doc.createElement("a");
+ link.href = "#" + flag.anchor;
+ link.textContent = flag.placeholder.textContent;
+ flag.placeholder.replaceChild(link, flag.placeholder.firstChild);
+ }
}
+ }
},
_parseData: function (name, str) {
- var items = str.replace('\u2011', '-', 'g').split(', '), flags = [];
- for (var i = 0; i < items.length; ++i) {
- if (!items[i].length)
- continue;
+ var items = str.replace('\u2011', '-', 'g').split(', '), flags = [];
+ for (var i = 0; i < items.length; ++i) {
+ if (!items[i].length)
+ continue;
- var match = this._reParseRequest.exec(items[i]);
- if (match) {
- var flag = {};
- flag.name = match[1];
- flag.setter = name;
- if (match[4]) {
- flag.requestee = match[4];
- }
- flag.type = match[2];
- flags.push(new AttachmentFlag(flag));
- }
+ var match = this._reParseRequest.exec(items[i]);
+ if (match) {
+ var flag = {};
+ flag.name = match[1];
+ flag.setter = name;
+ if (match[4]) {
+ flag.requestee = match[4];
+ }
+ flag.type = match[2];
+ flags.push(new AttachmentFlag(flag));
}
- return flags;
+ }
+ return flags;
},
_counter: 1,
get anchorName() {
- return "attachflag" + this._counter;
+ return "attachflag" + this._counter;
},
_reParseRequest: /^(.+)([\?\-\+])(\((.+)@.+\))?$/,
_reParseInterestingFlag: /^(.+):\s+(.+)(([\-\+])|\?(\s+(\((.+)\)))?)$/,
@@ -695,100 +855,100 @@ AttachmentFlagHandlerCtor.prototype = {
};
function CheckinCommentCtor() {
- this.bugNumber = null;
- this.summarySpan = null;
- this.checkinFlags = "";
+ this.bugNumber = null;
+ this.summarySpan = null;
+ this.checkinFlags = "";
}
CheckinCommentCtor.prototype = {
- initialize: function(doc, flags) {
- this.bugNumber = getBugNumber(doc);
- var summarySpan = doc.getElementById("short_desc_nonedit_display");
- if (summarySpan) {
+ initialize: function(doc, flags) {
+ this.bugNumber = getBugNumber(doc);
+ var summarySpan = doc.getElementById("short_desc_nonedit_display");
+ if (summarySpan) {
this.summary = summarySpan.textContent;
- }
- var checkinFlagsMap = {};
- for (var id in flags) {
+ }
+ var checkinFlagsMap = {};
+ for (var id in flags) {
for (var i = 0; i < flags[id].length; ++i) {
- var flag = flags[id][i];
- if (flag.type == "+") {
- var name = flag.name;
- if (name == "review") {
- name = "r";
- } else if (name == "superreview") {
- name = "sr";
- } else if (name == "ui-review") {
- name = "ui-r";
- } else if (name == "feedback") {
- name = "f";
- }
- if (!(name in checkinFlagsMap)) {
- checkinFlagsMap[name] = {};
- }
- checkinFlagsMap[name][flag.setter]++;
+ var flag = flags[id][i];
+ if (flag.type == "+") {
+ var name = flag.name;
+ if (name == "review") {
+ name = "r";
+ } else if (name == "superreview") {
+ name = "sr";
+ } else if (name == "ui-review") {
+ name = "ui-r";
+ } else if (name == "feedback") {
+ name = "f";
+ }
+ if (!(name in checkinFlagsMap)) {
+ checkinFlagsMap[name] = {};
}
+ checkinFlagsMap[name][flag.setter]++;
+ }
}
- }
- var flagsOrdered = [];
- for (var name in checkinFlagsMap) {
+ }
+ var flagsOrdered = [];
+ for (var name in checkinFlagsMap) {
flagsOrdered.push(name);
- }
- flagsOrdered.sort(function (a, b) {
+ }
+ flagsOrdered.sort(function (a, b) {
function convertToNumber(x) {
- switch (x) {
- case "f":
- return -4;
- case "r":
- return -3;
- case "sr":
- return -2;
- case "ui-r":
- return -1;
- default:
- return 0;
- }
+ switch (x) {
+ case "f":
+ return -4;
+ case "r":
+ return -3;
+ case "sr":
+ return -2;
+ case "ui-r":
+ return -1;
+ default:
+ return 0;
+ }
}
var an = convertToNumber(a);
var bn = convertToNumber(b);
if (an == 0 && bn == 0) {
- return a < b ? -1 : (a = b ? 0 : 1);
+ return a < b ? -1 : (a = b ? 0 : 1);
} else {
- return an - bn;
+ return an - bn;
}
- });
- var checkinFlags = [];
- for (var i = 0; i < flagsOrdered.length; ++i) {
+ });
+ var checkinFlags = [];
+ for (var i = 0; i < flagsOrdered.length; ++i) {
var name = flagsOrdered[i];
var flag = name + "=";
var setters = [];
for (var setter in checkinFlagsMap[name]) {
- setters.push(setter);
+ setters.push(setter);
}
flag += setters.join(",");
checkinFlags.push(flag);
- }
- this.checkinFlags = checkinFlags.join(" ");
- if (this.isValid()) {
- var div = doc.createElement("div");
- div.setAttribute("style", "display: none;");
- div.id = "__bz_tw_checkin_comment";
- div.appendChild(doc.createTextNode(this.toString()));
- doc.body.appendChild(div);
- }
- },
- isValid: function() {
+ }
+ this.checkinFlags = checkinFlags.join(" ");
+ if (this.isValid()) {
+ var div = doc.createElement("div");
+ div.setAttribute("style", "display: none;");
+ div.id = "__bz_tw_checkin_comment";
+ div.appendChild(doc.createTextNode(this.toString()));
+ doc.body.appendChild(div);
+ }
+ },
+ isValid: function() {
return this.bugNumber != null &&
- this.summary != null;
- },
- toString: function() {
- if (!this.isValid()) {
+ this.summary != null;
+ },
+ toString: function() {
+ if (!this.isValid()) {
return "";
- }
- var message = "Bug " + this.bugNumber + " - " + this.summary;
- if (this.checkinFlags.length) {
+ }
+ var message = "Bug " + this.bugNumber + " - " + this.summary;
+ if (this.checkinFlags.length) {
message += "; " + this.checkinFlags;
+ }
+ return message;
}
- return message;
- }
};
function DataStoreCtor(doc) {
@@ -807,7 +967,7 @@ function DataStoreCtor(doc) {
var count = window.localStorage.length;
if (count > 0) {
if (window.confirm("You currently have data stored for " + count + " bugs.\n\n" +
- "Are you sure you want to clear this data? This action cannot be undone.")) {
+ "Are you sure you want to clear this data? This action cannot be undone.")) {
window.localStorage.clear();
}
} else {
@@ -816,110 +976,110 @@ function DataStoreCtor(doc) {
}
var script = doc.createElement("script");
script.appendChild(doc.createTextNode(visualizeStoredData.toSource() +
- clearStoredData.toSource() +
- htmlEncode.toSource()));
+ clearStoredData.toSource() +
+ htmlEncode.toSource()));
doc.body.appendChild(script);
this.initialize(doc);
}
DataStoreCtor.prototype = {
- initialize: function(doc) {
- this.bugNumber = getBugNumber(doc);
- var data = this._ensureEntry(this.bugNumber, this.data);
- // last visited date
- data.visitedTime = (new Date()).getTime();
- // last comment count
- data.commentCount = doc.querySelectorAll(".bz_comment").length;
- // last status of bug flags
- var flags = this._ensureEntry("flags", data);
- var flagRows = doc.querySelectorAll("#flags tr");
- for (var i = 0; i < flagRows.length; ++i) {
- var flagCols = flagRows[i].querySelectorAll("td");
- if (flagCols.length != 3) {
- continue;
- }
- var flagName = trimContent(flagCols[1]);
- var flagValue = flagCols[2].querySelector("select");
- if (flagValue) {
- flagValue = flagValue.value;
- } else {
- continue;
- }
- flags[flagName] = flagValue;
- }
- flagRows = doc.querySelectorAll(".field_label[id^=field_label_cf_]");
- for (var i = 0; i < flagRows.length; ++i) {
- var flagName = trimContent(flagRows[i]).replace(/:$/, "");
- var flagValue = flagRows[i].parentNode.querySelector("select");
- if (flagValue) {
- flagValue = flagValue.value;
- } else {
- continue;
+ initialize: function(doc) {
+ this.bugNumber = getBugNumber(doc);
+ var data = this._ensureEntry(this.bugNumber, this.data);
+ // last visited date
+ data.visitedTime = (new Date()).getTime();
+ // last comment count
+ data.commentCount = doc.querySelectorAll(".bz_comment").length;
+ // last status of bug flags
+ var flags = this._ensureEntry("flags", data);
+ var flagRows = doc.querySelectorAll("#flags tr");
+ for (var i = 0; i < flagRows.length; ++i) {
+ var flagCols = flagRows[i].querySelectorAll("td");
+ if (flagCols.length != 3) {
+ continue;
+ }
+ var flagName = trimContent(flagCols[1]);
+ var flagValue = flagCols[2].querySelector("select");
+ if (flagValue) {
+ flagValue = flagValue.value;
+ } else {
+ continue;
+ }
+ flags[flagName] = flagValue;
}
- flags[flagName] = flagValue;
- }
- // last attachments
- var attachmentTable = doc.getElementById("attachment_table");
- var attachmentRows = attachmentTable.querySelectorAll("tr");
- for (var i = 0; i < attachmentRows.length; ++i) {
- var attachmentCells = attachmentRows[i].querySelectorAll("td");
- if (attachmentCells.length != 3) {
- continue;
+ flagRows = doc.querySelectorAll(".field_label[id^=field_label_cf_]");
+ for (var i = 0; i < flagRows.length; ++i) {
+ var flagName = trimContent(flagRows[i]).replace(/:$/, "");
+ var flagValue = flagRows[i].parentNode.querySelector("select");
+ if (flagValue) {
+ flagValue = flagValue.value;
+ } else {
+ continue;
+ }
+ flags[flagName] = flagValue;
}
- var link = attachmentCells[0].querySelector("a");
- var match = this._reAttachmentHref.exec(link.href);
- if (match) {
- var attachmentID = match[1];
- var attachment = this._ensureEntry("attachments", data);
- var attachmentFlags = this._ensureArray(attachmentID, attachment);
- for (var el = attachmentCells[1].firstChild; el.nextSibling; el = el.nextSibling) {
- if (el.nodeType != el.TEXT_NODE) {
- continue;
- }
- var text = trimContent(el);
- if (!text) {
- continue;
- }
- match = this._reParseInterestingFlag.exec(text);
- if (match) {
- var flag = {};
- flag.setter = match[1];
- flag.name = match[2];
- if (match[4] == "+" || match[4] == "-") {
+ // last attachments
+ var attachmentTable = doc.getElementById("attachment_table");
+ var attachmentRows = attachmentTable.querySelectorAll("tr");
+ for (var i = 0; i < attachmentRows.length; ++i) {
+ var attachmentCells = attachmentRows[i].querySelectorAll("td");
+ if (attachmentCells.length != 3) {
+ continue;
+ }
+ var link = attachmentCells[0].querySelector("a");
+ var match = this._reAttachmentHref.exec(link.href);
+ if (match) {
+ var attachmentID = match[1];
+ var attachment = this._ensureEntry("attachments", data);
+ var attachmentFlags = this._ensureArray(attachmentID, attachment);
+ for (var el = attachmentCells[1].firstChild; el.nextSibling; el = el.nextSibling) {
+ if (el.nodeType != el.TEXT_NODE) {
+ continue;
+ }
+ var text = trimContent(el);
+ if (!text) {
+ continue;
+ }
+ match = this._reParseInterestingFlag.exec(text);
+ if (match) {
+ var flag = {};
+ flag.setter = match[1];
+ flag.name = match[2];
+ if (match[4] == "+" || match[4] == "-") {
flag.type = match[4];
- } else {
+ } else {
flag.type = "?";
if (match[7]) {
- flag.requestee = match[7];
+ flag.requestee = match[7];
}
+ }
+ attachmentFlags.push(flag);
}
- attachmentFlags.push(flag);
}
}
}
- }
- // Write data to storage
- for (var key in this.data) {
- this._ensure(key, this.storage, JSON.stringify(this.data[key]));
- }
- },
- _ensure: function(entry, obj, val) {
- if (obj.toString().indexOf("[object Storage") >= 0) {
- obj.setItem(entry, val);
- } else {
- if (typeof obj[entry] == "undefined")
- obj[entry] = val;
- return obj[entry];
- }
- },
- _ensureEntry: function(entry, obj) {
- return this._ensure(entry, obj, {});
- },
- _ensureArray: function(entry, obj) {
- return this._ensure(entry, obj, []);
- },
- _reParseInterestingFlag: /^(.+):\s+(.+)(([\-\+])|\?(\s+(\((.+)\)))?)$/,
- _reAttachmentHref: /attachment\.cgi\?id=(\d+)$/i
+ // Write data to storage
+ for (var key in this.data) {
+ this._ensure(key, this.storage, JSON.stringify(this.data[key]));
+ }
+ },
+ _ensure: function(entry, obj, val) {
+ if (obj.toString().indexOf("[object Storage") >= 0) {
+ obj.setItem(entry, val);
+ } else {
+ if (typeof obj[entry] == "undefined")
+ obj[entry] = val;
+ return obj[entry];
+ }
+ },
+ _ensureEntry: function(entry, obj) {
+ return this._ensure(entry, obj, {});
+ },
+ _ensureArray: function(entry, obj) {
+ return this._ensure(entry, obj, []);
+ },
+ _reParseInterestingFlag: /^(.+):\s+(.+)(([\-\+])|\?(\s+(\((.+)\)))?)$/,
+ _reAttachmentHref: /attachment\.cgi\?id=(\d+)$/i
};
function getBugNumber(doc) {
@@ -940,37 +1100,37 @@ function getUserName(doc) {
}
function handleEmptyCollapsedBoxes(doc) {
- // first, try to get the display style of a CC field (any would do)
- var historyBoxes = doc.querySelectorAll(".bztw_history");
- for (var i = 0; i < historyBoxes.length; ++i) {
- var box = historyBoxes[i];
- for (var j = 0; j < box.childNodes.length; ++j) {
- var child = box.childNodes[j], found = true;
- if (child.nodeType != child.ELEMENT_NODE)
- continue;
- if (child.className == "sep") {
- // separators are insignificant
- continue;
- } else if (!/bztw_cc/.test(child.className)) {
- found = false;
- break;
- }
- }
- if (found) {
- box.className += " bztw_cc";
- }
+ // first, try to get the display style of a CC field (any would do)
+ var historyBoxes = doc.querySelectorAll(".bztw_history");
+ for (var i = 0; i < historyBoxes.length; ++i) {
+ var box = historyBoxes[i];
+ for (var j = 0; j < box.childNodes.length; ++j) {
+ var child = box.childNodes[j], found = true;
+ if (child.nodeType != child.ELEMENT_NODE)
+ continue;
+ if (child.className == "sep") {
+ // separators are insignificant
+ continue;
+ } else if (!/bztw_cc/.test(child.className)) {
+ found = false;
+ break;
+ }
}
+ if (found) {
+ box.className += " bztw_cc";
+ }
+ }
}
function applyClass(class_, html) {
- return '<span class="' + class_ + '">' + html + '</span>';
+ return '<span class="' + class_ + '">' + html + '</span>';
}
function htmlEncode(str) {
- return str.replace('&', '&amp;', 'g')
- .replace('<', '&lt;', 'g')
- .replace('>', '&gt;', 'g')
- .replace('"', '&quot;', 'g');
+ return str.replace('&', '&amp;', 'g')
+ .replace('<', '&lt;', 'g')
+ .replace('>', '&gt;', 'g')
+ .replace('"', '&quot;', 'g');
}
function tbplbotSpamCollapser(d) {
@@ -988,9 +1148,9 @@ function tbplbotSpamCollapser(d) {
var comment = comments[i];
try {
if (comment.querySelector(".bz_comment_user a.email").href.substr(7) ==
- "tbplbot@gmail.com") {
+ "tbplbot@gmail.com") {
win.collapse_comment(comment.querySelector(".bz_collapse_comment"),
- comment.querySelector(".bz_comment_text"));
+ comment.querySelector(".bz_comment_text"));
}
} catch (e) {
continue;
@@ -1003,5 +1163,3 @@ function tbplbotSpamCollapser(d) {
li.appendChild(a);
collapseExpandBox.appendChild(li);
}
-
-tweakBugzilla(document);
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index c85d331..aa2d0b7 100644
--- a/lib/libbugzilla.js
+++ b/lib/libbugzilla.js
@@ -40,7 +40,7 @@ function log(msg) {
/**
* parse XML object out of string working around various bugs in Gecko
* implementation see https://developer.mozilla.org/en/E4X for more information
- *
+ *
* @param inStr
* String with unparsed XML string
* @return XML object
@@ -57,7 +57,7 @@ function parseXMLfromString (inStuff) {
/**
* In case URL contains alias, not the real bug number, get the real bug no from
* the XML representation. Sets correct value to this.bugNo.
- *
+ *
* This is a slow variant for bugs other than actual window
*/
function getRealBugNoSlow(bugNo, location, callback) {
@@ -144,10 +144,10 @@ exports.changeJSONURL = function changeJSONURL() {
};
/**
- *
+ *
* libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
* worker.postMessage(pkgsMsg);
- *
+ *
* locationLoginObj: { location: window.location.href, login: getLogin() }
*/
exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, callback) {
@@ -288,36 +288,63 @@ exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment)
exports.makeXMLRPCCall = function makeXMLRPCCall(url, login, method, params, callback) {
var urlObj = urlMod.URL(url);
getPassword(login,
- urlObj.schema + "://" + urlObj.host,
- function (passwObj) {
- if (!passwObj.password) {
- // TODO this should happen, only when user presses Escape in password
- // prompt
- return null;
- }
+ urlObj.schema + "://" + urlObj.host,
+ function (passwObj) {
+ if (!passwObj.password) {
+ // TODO this should happen, only when user presses Escape in password
+ // prompt
+ return null;
+ }
- var msg = new xrpc.XMLRPCMessage(method);
- params.forEach(function (par) {
- msg.addParameter(par);
- });
- msg.addParameter(login);
- msg.addParameter(passwObj.password);
-
- Request({
- url: url,
- onComplete: function(response) {
- if (response.status == 200) {
- var resp = parseXMLfromString(response.text);
- callback(resp.toXMLString());
- }
- },
- content: msg.xml(),
- contentType: "text/xml"
- }).post();
- }
+ var msg = new xrpc.XMLRPCMessage(method);
+ params.forEach(function (par) {
+ msg.addParameter(par);
+ });
+ msg.addParameter(login);
+ msg.addParameter(passwObj.password);
+
+ Request({
+ url: url,
+ onComplete: function(response) {
+ if (response.status == 200) {
+ var resp = parseXMLfromString(response.text);
+ callback(resp.toXMLString());
+ }
+ },
+ content: msg.xml(),
+ contentType: "text/xml"
+ }).post();
+ }
);
};
+// Make a JSONL-RPC call ... most of the business logic should stay in the
+// content script
+// http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html
+exports.makeJSONRPCCall = function makeJSONRPCCall(url, method, params, callback) {
+
+// {"version":"1.1", "method":"Bug.history", "params":{ "ids":[12345] } }
+ var msg = {
+ "version": "1.1",
+ "method": method,
+ "params": params
+ };
+
+ console.myDebug("makeJSONRPCCall: out = " + JSON.stringify(msg));
+
+ Request({
+ url: url,
+ onComplete: function(response) {
+ if (response.status == 200) {
+ console.myDebug("makeJSONRPCCall: in = " + response.text);
+ callback(response.json.result);
+ }
+ },
+ content: JSON.stringify(msg),
+ contentType: "application/json"
+ }).post();
+};
+
exports.initialize = function initialize(config, callback) {
var prefName = BTSPrefNS+"JSONURL";
var urlStr = "";
diff --git a/lib/main.js b/lib/main.js
index c7fe2fd..302dda8 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -99,6 +99,15 @@ var messageHandler = exports.messageHandler = function messageHandler(
ret));
});
break;
+ case "MakeJSONRPCall":
+ // url, login, method, params, callback
+ libbz
+ .makeJSONRPCCall(msg.data.url, msg.data.method,
+ msg.data.params, function(ret) {
+ worker.postMessage(new Message(msg.data.callRPC,
+ ret));
+ });
+ break;
case "GetURL":
libbz.getURL(msg.data.url,
function(stuff) {
@@ -123,7 +132,7 @@ var contentScriptLibraries = [
self.data.url("lib/util.js"),
self.data.url("lib/jumpNextBug.js"),
self.data.url("lib/queries.js"),
- self.data.url("lib/preprocessDuplicates.js"),
+ self.data.url("tweaks/preprocessDuplicates.js"),
self.data.url("tweaks/viewSource.js"),
self.data.url("lib/color.js"),
self.data.url("tweaks/addNewLinks.js"),