aboutsummaryrefslogtreecommitdiffstats
path: root/bugzillaBugTriage.js
diff options
context:
space:
mode:
Diffstat (limited to 'bugzillaBugTriage.js')
-rw-r--r--bugzillaBugTriage.js90
1 files changed, 37 insertions, 53 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js
index eb1668b..ec6efd9 100644
--- a/bugzillaBugTriage.js
+++ b/bugzillaBugTriage.js
@@ -147,6 +147,25 @@ loadJSON(PCIIDsURL,
PCI_ID_Array = response;
});
+//======== load external library ===============================
+
+var XMLRPCMessage = {};
+var req = new XMLHttpRequest();
+req.open("GET","http://mcepl.fedorapeople.org/scripts/xmlrpc.js",true);
+req.onreadystatechange = function (aEvt) {
+ if (req.readyState == 4) {
+ if (req.status == 200) {
+ var thisDoc = jetpack.tabs.focused.contentDocument;
+ var script = thisDoc.createElement("script");
+ script.setAttribute("type","text/javascript");
+ script.innerHTML = req.responseText;
+ thisDoc.getElementsByTagName("head")[0].appendChild(script);
+ XMLRPCMessage = jetpack.tabs.focused.contentWindow.wrappedJSObject.XMLRPCMessage;
+ }
+ }
+};
+req.send("");
+
//==============================================================
/**
@@ -1243,16 +1262,13 @@ BzPage.prototype.callBack = function(data,textStatus) {
};
/**
- * Create XML-RPC message for updateAttachMimeType procedure with given parameters.
- * Yes, I know this is very ugly, but in the current state of jetpack it is not possible
- * to import external jQuery modules, so I cannot use jquery.rpc as much as I would like to.
+ * The worker function -- call XMLRPC to fix MIME type of the
+ * particular attachment
*
- * @param login string with login
- * @param password string with password
- * @param attachID Number with the attachment ID#
- * @param mimeType stri ng with MIME type, optional and defaults to text/plain
- * @param email Boolean whether we should send email or not
- * @return string with the XML-RPC message
+ * @param id integer with the attachment id to be fixed
+ * @param type string with the new MIME type, optional defaults to "text/plain"
+ * @param email Boolean whether email should be sent to appropriate person; option,
+ defaults to false
updateAttachMimeType($data_ref, $username, $password)
@@ -1266,56 +1282,24 @@ Update the attachment mime type of an attachment. The first argument is a data h
"nomail" => 0,
# OPTIONAL Flag that is either 1 or 0 if you want email to be sent or not for this change
};
+
*/
-BzPage.prototype.createXMLRPCMessage = function(login,password,attachId,mimeType,email) {
- if (mimeType === undefined) {
- mimeType = "text/plain";
+BzPage.prototype.fixAttachById = function(id,type,email) {
+ if (type === undefined) {
+ type = "text/plain";
}
if (email === undefined) {
email = false;
}
- var emailStr = email ? "0" : "1";
-
- var msg = <methodCall>
- <methodName>bugzilla.updateAttachMimeType</methodName>
- <params>
- <param>
- <value><struct>
- <member>
- <name>attach_id</name>
- <value><i4>{attachId}</i4></value>
- </member>
- <member>
- <name>mime_type</name>
- <value><string>{mimeType}</string></value>
- </member>
- <member>
- <name>nomail</name>
- <value><boolean>{emailStr}</boolean></value>
- </member>
- </struct></value>
- </param>
- <param>
- <value><string>{login}</string></value>
- </param>
- <param>
- <value><string>{password}</string></value>
- </param>
- </params>
- </methodCall>;
- return msg.toXMLString();
-};
-/**
- * The worker function -- call XMLRPC to fix MIME type of the
- * particular attachment
- *
- * @param id integer with the attachment id to be fixed
- * @param type string with the new MIME type, e.g. "text/plain"
- */
-BzPage.prototype.fixAttachById = function(id,type) {
- var msg = this.createXMLRPCMessage(this.login,this.password,id,type);
+ var msg = new XMLRPCMessage("bugzilla.updateAttachMimeType");
+ msg.addParameter({'attach_id':id, 'mime_type':type, 'nomail':!email});
+ msg.addParameter(this.login);
+ msg.addParameter(this.password);
+ console.log("testing XMLRPCMessage:\n" + msg.xml());
+
var req = new XMLHttpRequest();
+ var that = this;
req.open("POST",XMLRPCurl,true);
req.overrideMimeType("text/xml");
req.setRequestHeader("Content-type","text/xml");
@@ -1329,7 +1313,7 @@ BzPage.prototype.fixAttachById = function(id,type) {
}
}
};
- req.send(msg);
+ req.send(msg.xml());
this.reqCounter++;
};