aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rhbzpage.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-06-30 01:13:19 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-06-30 01:13:19 +0200
commit10ba5aaadd5c4f4bc5a769c2778ef26f952bb5a7 (patch)
tree09761465da097e065c398d2805332d8b7447dcae /lib/rhbzpage.js
parent984c66b9db41ccb8d338df993cf16cde2ff68068 (diff)
downloadbugzilla-triage-10ba5aaadd5c4f4bc5a769c2778ef26f952bb5a7.tar.gz
Use 'request' module instead of home brewed load{Text,JSON} and httpPOST
Diffstat (limited to 'lib/rhbzpage.js')
-rw-r--r--lib/rhbzpage.js74
1 files changed, 45 insertions, 29 deletions
diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js
index f61a88b..17b852e 100644
--- a/lib/rhbzpage.js
+++ b/lib/rhbzpage.js
@@ -5,11 +5,11 @@
var util = require("util");
var xrpc = require("xmlrpc");
var apiUtils = require("api-utils");
-var xhr = require("xhr");
var self = require("self");
var clip = require("clipboard");
var Color = require("color").Color;
var BZPage = require("bzpage").BZPage;
+var Request = require("request").Request;
var url = require("url");
var timer = require("timer");
var selection = require("selection");
@@ -263,14 +263,18 @@ RHBugzillaPage.prototype.pasteBacktraceInComments = function() {
attURL = "https://bugzilla.redhat.com/attachment.cgi?id="
+ x[1];
if (!this.btSnippet) {
- var btRaw = util.loadText(attURL, function(ret) {
- this.btSnippet = this.parseBacktrace(ret);
- if (this.btSnippet) {
- this.addStuffToTextBox("comment", this.btSnippet);
- this.addStuffToTextBox("status_whiteboard",
- "btparsed");
+ var that = this;
+ Request({
+ url: attURL,
+ onComplete: function() {
+ that.btSnippet = that.parseBacktrace(this.response.text);
+ if (that.btSnippet) {
+ that.addStuffToTextBox("comment", that.btSnippet);
+ that.addStuffToTextBox("status_whiteboard",
+ "btparsed");
+ }
}
- }, this);
+ }).get();
}
}, this);
}
@@ -506,27 +510,30 @@ RHBugzillaPage.prototype.fillInChipMagic = function () {
XorgLogAttID = this.XorgLogAttList[this.XorgLogAttListIndex][1];
attURL = "https://bugzilla.redhat.com/attachment.cgi?id="+XorgLogAttID;
- that = this;
+ var that = this;
// parse Xorg.0.log
- util.loadText(attURL, function(ret){
- var interestingLineArr = ret.split("\n").
- filter(function (v,i,a) {
- return that.RE.Chipset.test(v);
- });
- if (interestingLineArr.length >0) {
- // TODO we are parsing only the first found line; is it alright?
- interestingArray = that.RE.Chipset.exec(interestingLineArr[0]);
- interestingLine = interestingArray[2].
- replace(/[\s"]+/g," ").trim();
- // Persuade createNewButton to have mercy and to actually add
- // non-default button
- that.constantData.chipMagicTrigger = true;
- that.chipMagicInterestingLine = interestingLine+"\t"+interestingArray[1]
- .toUpperCase();
- that.createNewButton("status_whiteboard", true, "rh-xorg", "chipMagic");
+ Request({
+ url: attURL,
+ onComplete: function () {
+ var interestingLineArr = this.response.text.split("\n").
+ filter(function (v,i,a) {
+ return that.RE.Chipset.test(v);
+ });
+ if (interestingLineArr.length >0) {
+ // TODO we are parsing only the first found line; is it alright?
+ interestingArray = that.RE.Chipset.exec(interestingLineArr[0]);
+ interestingLine = interestingArray[2].
+ replace(/[\s"]+/g," ").trim();
+ // Persuade createNewButton to have mercy and to actually add
+ // non-default button
+ that.constantData.chipMagicTrigger = true;
+ that.chipMagicInterestingLine = interestingLine+"\t"+interestingArray[1]
+ .toUpperCase();
+ that.createNewButton("status_whiteboard", true, "rh-xorg", "chipMagic");
+ }
}
- });
+ }).get();
this.XorgLogAttListIndex++;
};
@@ -693,7 +700,7 @@ RHBugzillaPage.prototype.fixElement = function(elem, beforeText, accKey, afterTe
*/
RHBugzillaPage.prototype.getBugzillaName = function(URLhostname) {
var bugzillaID = "";
- var bzLabelNames = JSON.parse(self.data.load("bugzillalabelNames.json"));
+ var bzLabelNames = JSON.parse(self.data.load("bugzillalabelNames.json"));
if (bzLabelNames[URLhostname]) {
bugzillaID = bzLabelNames[URLhostname];
} else {
@@ -752,6 +759,7 @@ RHBugzillaPage.prototype.fixAttachById = function(id, type, email) {
email = false;
}
+ var that = this;
var msg = new xrpc.XMLRPCMessage("bugzilla.updateAttachMimeType");
msg.addParameter( {
'attach_id' : id,
@@ -764,8 +772,16 @@ RHBugzillaPage.prototype.fixAttachById = function(id, 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
- util.httpPOST(this.XMLRPCurl, msg.xml(), this.fixingMIMECallBack,
- this, "text/xml", "text/xml");
+ Require({
+ url: this.XMLRPCurl,
+ onComplete: function() {
+ that.fixingMIMECallBack.call(that);
+ },
+ data: msg.xml(),
+ contentType: "text/xml",
+ });
+// util.httpPOST(this.XMLRPCurl, msg.xml(), this.fixingMIMECallBack,
+// this, "text/xml", "text/xml");
this.reqCounter++;
};