diff options
Diffstat (limited to 'lib/libbugzilla.js')
-rw-r--r-- | lib/libbugzilla.js | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index ceea270..e074072 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -7,7 +7,7 @@ var preferences = require("preferences-service"); var prompts = require("prompts"); var clipboard = require("clipboard"); var tabs = require("tabs"); -var logger = require("logger"); +//var logger = require("logger"); var passUtils = require("passwords"); var Request = require("request").Request; @@ -18,6 +18,16 @@ var BTSPassRealm = "BTSXMLRPCPass"; var config = {}; +function Message(cmd, data) { + console.log("Message: cmd = " + cmd + ", data = " + data); + this.cmd = cmd; + this.data = data; +} + +function log(msg) { + postMessage(new Message("LogMessage", msg)); +} + /** * parse XML object out of string working around various bugs in Gecko implementation * see https://developer.mozilla.org/en/E4X for more information @@ -115,8 +125,12 @@ exports.changeJSONURL = function changeJSONURL() { exports.getInstalledPackages = function getInstalledPackages(location, callback) { var installedPackages = {}; var enabledPackages = []; + + console.log("location = " + location.toString()); + console.log("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; @@ -135,9 +149,12 @@ 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]; } @@ -145,14 +162,20 @@ exports.getInstalledPackages = function getInstalledPackages(location, callback) } // Expand commentIdx properties into full comments - installedPackages.forEach(function (pkg) { - pkg.forEach(function (cmdObj) { + 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]; delete cmdObj.commentIdx; } - }); - }); + } + } + + console.log("after // installedPackages = " + installedPackages.toSource()); + callback(new Message("CreateButtons", { instPkgs: installedPackages, constData: config.constantData @@ -264,10 +287,11 @@ function initialize() { if ("killNodes" in config.gJSONData.configData && window.location.hostname in config.gJSONData.configData.killNodes) { var killConf = config.gJSONData.configData.killNodes[window.location.hostname]; - util.killNodes(config.doc, killConf[0], killConf[1]); + killNodes(config.doc, killConf[0], killConf[1]); } } + callback(); } }).get(); } |