diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-06-22 17:18:44 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-06-22 17:18:44 +0200 |
commit | c1f7615fa2a5dcc15fa3ed7962016537dd31bbfd (patch) | |
tree | c166ac80ff488e8706161a4defb373ee71e13bcd /lib/rhbzpage.js | |
parent | 390f9042f82e4aaa6a57d08b9a5edfb38f688abf (diff) | |
download | bugzilla-triage-c1f7615fa2a5dcc15fa3ed7962016537dd31bbfd.tar.gz |
Make fixing MIME type again (includes creation of util.httpPOST)
- it is useful to have variable in the same module where the function using it
is.
- a lot of this magic and mystery
- add this.win property
- yuhooo, we have timer module, so I don't have to fish it from
this.doc.defaultView (which doesn't work anyway)
Diffstat (limited to 'lib/rhbzpage.js')
-rw-r--r-- | lib/rhbzpage.js | 87 |
1 files changed, 17 insertions, 70 deletions
diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index a6acff4..8ac1870 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -10,20 +10,18 @@ var clip = require("clipboard"); var Color = require("color").Color; var BZPage = require("bzpage").BZPage; var url = require("url"); +var timer = require("timer"); var selection = require("selection"); var tabs = require("tabs"); // var NumberOfFrames = 7; -// var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi"; // var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id="; // ==================================================================================== // RHBugzillaPage object -var RHBugzillaPage = function RHBugzillaPage(doc, config) { +var RHBugzillaPage = function RHBugzillaPage(win, config) { // inheritance ... call superobject's constructor - BZPage.call(this, doc, config); - - console.log("location = " + this.doc.location); + BZPage.call(this, win, config); // For identification of graphics card var manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ], @@ -52,6 +50,8 @@ var RHBugzillaPage = function RHBugzillaPage(doc, config) { signalHandler: new RegExp("^\\s*#[0-9]*\\s*<signal handler called>"), frameNo: new RegExp("^\\s*#([0-9]*)\\s") }; + + this.XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi"; // END OF CONSTANTS var that = this; @@ -336,14 +336,12 @@ RHBugzillaPage.prototype.setBranding = function() { var TriagedColor = {}; if (this.isEnterprise()) { - console.log("This is an enterprise bug."); if (this.its && (this.its.length > 0)) { brandColor = this.RHITColor; } else { brandColor = this.RHColor; } } else if (new RegExp("Fedora").test(this.product)) { - console.log("This is NOT an enterprise bug."); if (this.version === 999) { brandColor = this.RawhideColor; } else { @@ -533,12 +531,9 @@ RHBugzillaPage.prototype.fillInChipMagic = function () { RHBugzillaPage.prototype.getSelectionOrClipboard = function getSelectionOrClipboard () { var text = selection.text; - console.log("selection = " + text); if (!text) { text = clip.get(); - console.log("clipboard = " + text); } - console.log("text = " + text); return text; }; @@ -553,9 +548,6 @@ RHBugzillaPage.prototype.getSelectionOrClipboard = function getSelectionOrClipbo * */ RHBugzillaPage.prototype.queryInNewTab = function(text, component, product) { - console.log("queryInNewTab / text = " + text); - console.log("queryInNewTab / component = " + component); - console.log("queryInNewTab / product = " + product); var urlStr = "https://bugzilla.redhat.com/buglist.cgi?query_format=advanced"; if (product) { urlStr += "&product=" + product.trim(); @@ -711,11 +703,13 @@ RHBugzillaPage.prototype.getBugzillaName = function(URLhostname) { * + responseHeaders * + responseText */ -RHBugzillaPage.prototype.fixingMIMECallBack = function(data, textStatus) { +RHBugzillaPage.prototype.fixingMIMECallBack = function() { var that = this; + console.log("fixingMIMECallBack / that.doc = " + that.doc); + console.log("fixingMIMECallBack / that.win = " + that.win); if (--this.reqCounter <= 0) { - setTimeout(function () { - that.doc.location.reload(true); + timer.setTimeout(function () { + that.win.location.reload(true); }, 1000); } }; @@ -758,55 +752,12 @@ RHBugzillaPage.prototype.fixAttachById = function(id, type, email) { }); msg.addParameter(this.login); msg.addParameter(this.password); - console.log("msg.xml() = " + msg.xml()); -/* -https://bugzilla.redhat.com/docs/en/html/api/extensions/compat_xmlrpc/code/webservice.html -<methodCall> -<methodName>bugzilla.updateAttachMimeType</methodName> -<params> -<param> -<value><struct> -<member> -<name>attach_id</name> -<value><i4>388923</i4></value> -</member> -<member> -<name>mime_type</name> -<value><string>text/plain</string></value> -</member> -<member> -<name>nomail</name> -<value><boolean>1</boolean></value> -</member> -</struct> -</value> -</param> -<param> -<value><string>mcepl@redhat.com</string></value> -</param> -<param> -<value><string>kyrios</string></value> -</param> -</params> -</methodCall> -*/ - - var req = new XMLHttpRequest(); - var that = this; - req.open("POST", XMLRPCurl, true); - req.overrideMimeType("text/xml"); - req.setRequestHeader("Content-type", "text/xml"); - req.onreadystatechange = function(aEvt) { - if (req.readyState === 4) { - if (req.status === 200) { - console.log("Fixing attachment MIME type success!"); - that.fixingMIMECallBack(); - } else { - console.error("Fixing MIME type attachment failed!"); - } - } - }; - req.send(msg.xml()); + + // 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"); this.reqCounter++; }; @@ -873,10 +824,6 @@ RHBugzillaPage.prototype.addClosingUpstream = function() { wholeURL = inputBox.value; var helpURL = new url.URL(wholeURL); var paramsArr = helpURL.path.replace(/^\?/, '').split('&'); - console.log("wholeURL = " + wholeURL); - console.log("helpURL = " + helpURL); - console.log("helpURL.path = " + helpURL.path); - console.log("paramsArr = " + paramsArr.toSource()); // get convert URL parameters to an Object var params = {}, s = []; paramsArr.forEach(function(par, idx, arr) { @@ -971,4 +918,4 @@ RHBugzillaPage.prototype.parseBacktrace = function(ret) { }; // exports.RHBugzillaPage = apiUtils.publicConstructor(RHBugzillaPage); -exports.RHBugzillaPage = RHBugzillaPage;
\ No newline at end of file +exports.RHBugzillaPage = RHBugzillaPage; |