aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-01-20 17:51:29 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-01-20 17:51:29 +0100
commita8d92b4d8ef27e216b33781e014a35f55bf1be42 (patch)
tree3400885e5678ee6f963caf73e0818cf5efc6e72a /lib
parent8b145a758d12871e705adbd7689598edd5dfa6c3 (diff)
downloadbugzilla-triage-a8d92b4d8ef27e216b33781e014a35f55bf1be42.tar.gz
First rough removal of objects and transformation on plain functions.
TODO: * still this is all around the place * constructors has not been fixed * all require's were just yanked, but they are still used. * functions should be more self-contained ... tons of global variables everywhere.
Diffstat (limited to 'lib')
-rw-r--r--lib/main.js66
1 files changed, 63 insertions, 3 deletions
diff --git a/lib/main.js b/lib/main.js
index fbabd41..35d7d60 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -13,10 +13,11 @@
"use strict";
var logger = require("logger");
var browser = require("tab-browser");
-var selfMod = require("self");
+var self = require("self");
var Request = require("request").Request;
var preferences = require("preferences-service");
-var BTSPrefNS = require("bzpage").BTSPrefNS;
+var pageMod = require("page-mod");
+// var BTSPrefNS = require("bzpage").BTSPrefNS;
// Use my JSON for now before it is fixed for general public
var JSONURLDefault = "https://fedorahosted.org/released"+
"/bugzilla-triage-scripts/Config_data.json";
@@ -87,7 +88,7 @@ function initialize(callback) {
}, this);
}
- config.logger = new logger.Logger(JSON.parse(selfMod.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) {
@@ -108,6 +109,7 @@ function initialize(callback) {
}).get();
}
+/*
exports.main = function main(options, callbacks) {
initialize(function (config) {
browser.whenContentLoaded(
@@ -132,3 +134,61 @@ exports.main = function main(options, callbacks) {
);
});
};
+
+*/
+var messageHandler = exports.messageHandler = function messageHandler(worker, msg) {
+ switch (msg.cmd) {
+ case "LogMessage":
+ console.log(msg.data);
+ break;
+ case "GetDuplicatorID":
+ getDuplicatorID(msg.data.host, msg.data.bugID, function (msgObj) {
+ worker.postMessage(msgObj);
+ });
+ break;
+ case "GetPassword":
+ getPassword(msg.data.login, msg.data.hostname, function (pass) {
+ worker.postMessage(pass);
+ });
+ break;
+ case "DeDeduplicateQueue":
+ LoginData = {
+ queue: msg.data.bugs,
+ host: msg.data.hostname,
+ login: msg.data.login,
+ pass: msg.data.password,
+ dupID: msg.data.duplicator,
+ finalCallback: function (msgObj) {
+ worker.postMessage(msgObj);
+ }
+ };
+ processReqQueue();
+ break;
+ case "testReady":
+ // we ignore it here, interesting only in unit test
+ break;
+ default:
+ console.error(msg.toSource());
+ }
+};
+
+var contentScriptLibraries = {
+ "bugzilla.redhat.com": [
+ self.data.url("bzpage.js"),
+ self.data.url("rhbzpage.js")
+ ]
+};
+
+pageMod.PageMod({
+ include: [
+ "https://bugzilla.redhat.com/show_bug.cgi?id=*"
+ ],
+ contentScriptWhen: 'ready',
+ // contentScriptFile: contentScriptLibraries["bugzilla.redhat.com"],
+ onAttach: function onAttach(worker, msg) {
+ console.log("worker: " + worker);
+ worker.on('message', function (msg) {
+ messageHandler(worker, msg);
+ });
+ }
+});