aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libbugzilla.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libbugzilla.js')
-rw-r--r--lib/libbugzilla.js43
1 files changed, 17 insertions, 26 deletions
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index e074072..1c5f7a2 100644
--- a/lib/libbugzilla.js
+++ b/lib/libbugzilla.js
@@ -10,14 +10,14 @@ var tabs = require("tabs");
//var logger = require("logger");
var passUtils = require("passwords");
var Request = require("request").Request;
+var selfMod = require("self");
+var urlMod = require("url");
var JSONURLDefault = "https://fedorahosted.org/released"+
"/bugzilla-triage-scripts/Config_data.json";
var BTSPrefNS = "bugzilla-triage.setting.";
var BTSPassRealm = "BTSXMLRPCPass";
-var config = {};
-
function Message(cmd, data) {
console.log("Message: cmd = " + cmd + ", data = " + data);
this.cmd = cmd;
@@ -122,20 +122,23 @@ exports.changeJSONURL = function changeJSONURL() {
libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
worker.postMessage(pkgsMsg);
*/
-exports.getInstalledPackages = function getInstalledPackages(location, callback) {
+exports.getInstalledPackages = function getInstalledPackages(location, config, callback) {
var installedPackages = {};
var enabledPackages = [];
- console.log("location = " + location.toString());
- console.log("location = " + typeof location);
+ if (typeof location == "string") {
+ location = new urlMod.URL(location);
+ }
+
+ console.log("location = " + location);
+ console.log("typeof location = " + typeof location);
// Collect enabled packages per hostname (plus default ones)
- console.log("getInstalledPackages: config = " + config.toSource());
if (config.gJSONData && ("commentPackages" in config.gJSONData)) {
if ("enabledPackages" in config.gJSONData.configData) {
var epObject = config.gJSONData.configData.enabledPackages;
- if (location.hostname in epObject) {
- enabledPackages = enabledPackages.concat(epObject[location.hostname].split(/[,\s]+/));
+ if (location.host in epObject) {
+ enabledPackages = enabledPackages.concat(epObject[location.host].split(/[,\s]+/));
}
if ("any" in epObject) {
enabledPackages = enabledPackages.concat(epObject.any.split(/[,\s]+/));
@@ -149,12 +152,9 @@ exports.getInstalledPackages = function getInstalledPackages(location, callback)
}
}
- console.log("getInstalledPackages: enabledPackages = " + enabledPackages.toSource());
-
// TODO To be decided, whether we cannot just eliminate packages in
// installedPackages and having it just as a plain list of all cmdObjects.
enabledPackages.forEach(function (pkg, idx, arr) {
- console.log("getInstalledPackages: pkg = " + pkg);
if (pkg in config.gJSONData.commentPackages) {
installedPackages[pkg] = config.gJSONData.commentPackages[pkg];
}
@@ -162,23 +162,21 @@ exports.getInstalledPackages = function getInstalledPackages(location, callback)
}
// Expand commentIdx properties into full comments
- console.log("before // installedPackages = " + installedPackages.toSource());
var cmdObj = {};
for (var pkgKey in installedPackages) {
for (var cmdObjKey in installedPackages[pkgKey]) {
cmdObj = installedPackages[pkgKey][cmdObjKey];
if ("commentIdx" in cmdObj) {
- cmdObj.comment = config.commentStrings[cmdObj.commentIdx];
+ cmdObj.comment = config.gJSONData.commentStrings[cmdObj.commentIdx];
delete cmdObj.commentIdx;
}
}
}
- console.log("after // installedPackages = " + installedPackages.toSource());
-
callback(new Message("CreateButtons", {
instPkgs: installedPackages,
- constData: config.constantData
+ constData: config.constantData,
+ kNodes: config.gJSONData.configData.killNodes
}));
};
@@ -199,7 +197,7 @@ exports.openURLinNewTab = function openURLinNewTab(urlStr) {
});
};
-function initialize() {
+exports.initialize = function initialize(config, callback) {
var prefName = BTSPrefNS+"JSONURL";
var urlStr = "";
@@ -239,7 +237,7 @@ function initialize() {
});
}
- config.logger = new logger.Logger(JSON.parse(self.data.load("bugzillalabelAbbreviations.json")));
+ // config.logger = new logger.Logger(JSON.parse(self.data.load("bugzillalabelAbbreviations.json")));
config.matches = config.gJSONData.configData.matches;
config.skipMatches = config.matches.map(function(x) {
@@ -280,16 +278,9 @@ function initialize() {
if ("submitsLogging" in config.gJSONData.configData &&
config.gJSONData.configData.submitsLogging) {
- config.log = config.logger;
+ // config.log = config.logger;
// FIXME this.setUpLogging();
}
-
- if ("killNodes" in config.gJSONData.configData &&
- window.location.hostname in config.gJSONData.configData.killNodes) {
- var killConf = config.gJSONData.configData.killNodes[window.location.hostname];
- killNodes(config.doc, killConf[0], killConf[1]);
- }
-
}
callback();
}