aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-01-28 16:38:36 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-01-31 20:33:33 +0100
commit4a0bcc39b1e1b49dcaa0aa2ab674c6f1ba51e9e5 (patch)
tree642411d3b3b433e8903e0bbbbf46004a37477b58 /lib
parent83a7d703cbabd6e514a6d8a948b39325b59e9f58 (diff)
downloadbugzilla-triage-4a0bcc39b1e1b49dcaa0aa2ab674c6f1ba51e9e5.tar.gz
Tons of fixes, we are almost in state that the primitive run is possible.
TOOD: * The most important part is we have to run libbz.initialize() and wait until it is done.
Diffstat (limited to 'lib')
-rw-r--r--lib/libbugzilla.js36
-rw-r--r--lib/logger.js5
-rw-r--r--lib/main.js37
3 files changed, 38 insertions, 40 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();
}
diff --git a/lib/logger.js b/lib/logger.js
index f64a6e9..cbe670d 100644
--- a/lib/logger.js
+++ b/lib/logger.js
@@ -4,7 +4,6 @@
var urlMod = require("url");
var utilMod = require("util");
var fileMod = require("file");
-var Color = require("color").Color;
var tabs = require("tabs");
var prompts = require("prompts");
var apiUtils = require("api-utils");
@@ -12,8 +11,8 @@ var xrpc = require("xmlrpc");
var myStorage = require("simple-storage");
var Logger = exports.Logger = function Logger(abbsMap) {
- this.EmptyLogsColor = new Color(0, 255, 0);
- this.FullLogsColor = new Color(0, 40, 103);
+ this.EmptyLogsColor = rgb(0, 255, 0);
+ this.FullLogsColor = rgb(0, 40, 103);
if (!myStorage.storage.logs) {
myStorage.storage.logs = {};
diff --git a/lib/main.js b/lib/main.js
index cbb3ba6..0afa67d 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -41,35 +41,8 @@ function skipThisPage(doc) {
}
}
-
-/*
-exports.main = function main(options, callbacks) {
- initialize(function (config) {
- browser.whenContentLoaded(
- function(window) {
- // is this good for anything?
- if ("window" in window) { window = window.window; }
-
- if (isOurPage(window, config.matches)) {
- try {
- var curPage = new config.objConstructor(window, config);
- } catch (ex) {
- if (ex instanceof require("bzpage").NotLoggedinException) {
- return ; // Bail out if the user is not logged in
- } else {
- throw ex; // rethrow the exception otherwise
- }
- }
- } else if (isOurPage(window, config.skipMatches)) {
- skipThisPage(window.document);
- }
- }
- );
- });
-};
-
-*/
var messageHandler = exports.messageHandler = function messageHandler(worker, msg) {
+ console.log("messageHandler: msg = " + msg.toSource());
switch (msg.cmd) {
case "LogMessage":
console.log(msg.data);
@@ -79,6 +52,7 @@ var messageHandler = exports.messageHandler = function messageHandler(worker, ms
break;
case "GetInstalledPackages":
// send message with packages back
+ console.log("msg = " + msg.toSource());
libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
worker.postMessage(pkgsMsg);
});
@@ -106,17 +80,18 @@ var contentScriptLibraries = {
"bugzilla.redhat.com": [
self.data.url("util.js"),
self.data.url("color.js"),
- self.data.url("bzpage.js"),
- self.data.url("rhbzpage.js")
+ self.data.url("bzpage.js")
+// self.data.url("rhbzpage.js")
]
};
+libbz.initialize();
pageMod.PageMod({
include: [
"https://bugzilla.redhat.com/show_bug.cgi?id=*"
],
contentScriptWhen: 'ready',
- // contentScriptFile: contentScriptLibraries["bugzilla.redhat.com"],
+ contentScriptFile: contentScriptLibraries["bugzilla.redhat.com"],
onAttach: function onAttach(worker, msg) {
console.log("worker: " + worker);
worker.on('message', function (msg) {