aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/bzpage.js6
-rw-r--r--lib/clipboard.js2
-rw-r--r--lib/color.js2
-rw-r--r--lib/logger.js4
-rw-r--r--lib/main.js5
-rw-r--r--lib/mozillabzpage.js2
-rw-r--r--lib/rhbzpage.js87
-rw-r--r--lib/skip-process-bug.js46
-rw-r--r--lib/util.js35
-rw-r--r--lib/xmlrpc.js2
10 files changed, 63 insertions, 128 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js
index 4906d13..8061577 100644
--- a/lib/bzpage.js
+++ b/lib/bzpage.js
@@ -10,12 +10,11 @@ var Color = require("color").Color;
var TriagedDistro = 13;
var NumberOfFrames = 7;
-var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi";
var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id=";
// ====================================================================================
// BZPage's methods
-var BZPage = function BZPage(doc, config) {
+var BZPage = function BZPage(win, config) {
var keys = "";
for (var key in config) {
keys += key + ", ";
@@ -28,7 +27,8 @@ var BZPage = function BZPage(doc, config) {
this.ReporterColor = new Color(255, 255, 166); // RGB 255, 255, 166; HSL 60, 2,
// 83
// initialize dynamic properties
- this.doc = doc;
+ this.win = win;
+ this.doc = win.document;
this.packages = this.getInstalledPackages(config);
if ("commentStrings" in config.gJSONData) {
diff --git a/lib/clipboard.js b/lib/clipboard.js
index c601649..1870e9f 100644
--- a/lib/clipboard.js
+++ b/lib/clipboard.js
@@ -118,7 +118,7 @@ var flavorsMethod = exports.getCurrentFlavors = function flavorsMethod(test) {
clip.kGlobalClipboard
);
if (presentFlavor) {
- flavorArray.push(possibleTypes[flavor])
+ flavorArray.push(possibleTypes[flavor]);
}
}
return flavorArray;
diff --git a/lib/color.js b/lib/color.js
index 9a09707..574ad19 100644
--- a/lib/color.js
+++ b/lib/color.js
@@ -19,7 +19,7 @@ var Color = exports.Color = function Color(r, g, b) {
this.g = g;
this.b = b;
}
-}
+};
Color.prototype.update = function(r, g, b) {
this.r = r;
diff --git a/lib/logger.js b/lib/logger.js
index 0f7de76..01c626d 100644
--- a/lib/logger.js
+++ b/lib/logger.js
@@ -57,14 +57,14 @@ Logger.prototype.getLength = function () {
counter += 1;
}
return counter;
-}
+};
Logger.prototype.getBugzillaAbbr = function(url) {
// for https://bugzilla.redhat.com/show_bug.cgi?id=579123 get RH
// for https://bugzilla.mozilla.org/show_bug.cgi?id=579123 get MoFo
var abbr = this.abbsMap[urlMod.URL(url).host];
return abbr;
-}
+};
Logger.prototype.timeSheetRecordsPrinter = function(body, records) {
var that = this;
diff --git a/lib/main.js b/lib/main.js
index d1e518d..d572da3 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -124,7 +124,6 @@ exports.main = function main(options, callbacks) {
function(window) {
// is this good for anything?
if ("window" in window) { window = window.window; }
- var doc = window.document;
var construct = {};
var bzType = config.gJSONData.configData.objectStyle;
@@ -134,9 +133,9 @@ exports.main = function main(options, callbacks) {
construct = require("mozillabzpage").MozillaBugzilla;
}
if (isOurPage(window, config.matches)) {
- var curPage = new construct(doc, config);
+ var curPage = new construct(window, config);
} else if (isOurPage(window, config.skipMatches)) {
- skipThisPage(doc);
+ skipThisPage(window.document);
} else {
console.log("Not our page: " + window.location.href);
}
diff --git a/lib/mozillabzpage.js b/lib/mozillabzpage.js
index 9c82570..69e2926 100644
--- a/lib/mozillabzpage.js
+++ b/lib/mozillabzpage.js
@@ -8,7 +8,7 @@ var apiUtils = require("api-utils");
// MozillaBugzilla object
var MozillaBugzilla = function MozillaBugzilla (doc, config) {
- BZPage.call(this, doc, config)
+ BZPage.call(this, doc, config);
};
MozillaBugzilla.prototype = utilMod.heir(BZPage);
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;
diff --git a/lib/skip-process-bug.js b/lib/skip-process-bug.js
deleted file mode 100644
index f4e98cc..0000000
--- a/lib/skip-process-bug.js
+++ /dev/null
@@ -1,46 +0,0 @@
-jetpack.future.import("pageMods");
-
-// http://maymay.net/blog/2008/06/15/\
-// ridiculously-simple-javascript-version-string-to-object-parser/
-function parseVersionString (str) {
- if (typeof(str) != 'string') { return false; }
- var x = str.split('.');
- // parse from string or default to 0 if can't parse
- var maj = parseInt(x[0]) || 0;
- var min = parseInt(x[1]) || 0;
- var pat = parseInt(x[2]) || 0;
- return {
- major: maj,
- minor: min,
- patch: pat
- };
-}
-
-var callback = function(document){
- var stemURL = "https://HOSTNAME/show_bug.cgi?id=";
- var titleStr = $("title",document).text();
- var REArr = RegExp("[0-9]+").exec(titleStr);
- var REHostname = RegExp("\/\/([^/]+)\/").exec(document.location.toString());
- if (REArr) {
- var bugNo = REArr[0];
- var hostname = REHostname[1];
- console.log("bugNo = " + bugNo + ", hostname = " + hostname);
- var currentFFVersion = parseVersionString(jetpack.__parent__.navigator.vendorSub);
- console.log("currentFFVersion = " + currentFFVersion.toSource());
- if ((currentFFVersion.major >= 3) && (currentFFVersion.minor >= 6)) {
- var emailsSent = $("#bugzilla-body > dl:first",document).text();
- emailsSent = emailsSent.replace(/^(\s*)$/mg,"");
- jetpack.notifications.show(emailsSent);
- }
- document.location = stemURL.replace("HOSTNAME",hostname) + bugNo;
- }
-};
-
-var options = {};
-options.matches = [
- "https://bugzilla.redhat.com/process_bug.cgi",
- "https://bugzilla.redhat.com/post_bug.cgi",
- "https://bugzilla.mozilla.org/post_bug.cgi",
- "https://bugzilla.mozilla.org/process_bug.cgi"
- ];
-jetpack.pageMods.add(callback, options);
diff --git a/lib/util.js b/lib/util.js
index 02fd476..b165567 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -262,3 +262,38 @@ exports.loadJSON = function loadJSON(URL, cb_function, what) {
cb_function.call(what, data);
}, what);
};
+
+/**
+ * run HTTP POST request
+ *
+ * @param URL String with URL; required
+ * @param data Object/String with data ; required
+ * @param cb_function Function called when the request succeeds, with
+ * the only parameter being request object ; required
+ * @param what Object which will represent this for the cb_function ; optional
+ * @param mimeData String with MIME type of data
+ * @param mimeGet String with MIME type expected on return
+ */
+exports.httpPOST = function httpPOST(URL, data, cb_function, what, mimeData, mimeGet) {
+ what = what === undefined ? this : what;
+ mimeData = mimeData === undefined ? "application/x-www-form-urlencoded" : mimeData;
+ mimeGet = mimeGet === undefined ? "text/plain" : mimeGet;
+
+ var req = new xhrMod.XMLHttpRequest();
+ console.log("req = " + req.toSource());
+ req.open("POST", URL, true);
+
+ req.overrideMimeType(mimeGet);
+ req.setRequestHeader("Content-type", mimeData);
+ req.onreadystatechange = function(aEvt) {
+ if (req.readyState === 4) {
+ if (req.status === 200) {
+ console.log("POST success!");
+ cb_function.call(what, req);
+ } else {
+ console.error("POST failed!");
+ }
+ }
+ };
+ req.send(data);
+};
diff --git a/lib/xmlrpc.js b/lib/xmlrpc.js
index f074f39..7ae622c 100644
--- a/lib/xmlrpc.js
+++ b/lib/xmlrpc.js
@@ -19,7 +19,7 @@ var XMLRPCMessage = exports.XMLRPCMessage = function XMLRPCMessage(methodname) {
this.method = methodname || "system.listMethods";
this.params = [];
return this;
-}
+};
XMLRPCMessage.prototype.setMethod = function(methodName) {
if (!methodName) return;