aboutsummaryrefslogtreecommitdiffstats
path: root/lib/main.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-01-28 02:04:52 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-01-28 02:04:52 +0100
commit83a7d703cbabd6e514a6d8a948b39325b59e9f58 (patch)
treee1bf21f956c5f0e151bb254dec8771e22c3261df /lib/main.js
parent6424471ab36679138c1708ddaf97c40e6bf24155 (diff)
downloadbugzilla-triage-83a7d703cbabd6e514a6d8a948b39325b59e9f58.tar.gz
bzpage.js mostly done
Also: * created libbugzilla.js for putting aside most RPCed functions * utils.js and color.js moved to data * tons and tons of restructing to make things work via RPC
Diffstat (limited to 'lib/main.js')
-rw-r--r--lib/main.js104
1 files changed, 18 insertions, 86 deletions
diff --git a/lib/main.js b/lib/main.js
index 35d7d60..cbb3ba6 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -11,18 +11,11 @@
// http://ehsanakhgari.org/blog/2010-05-31/my-experience-jetpack-sdk#comment-1253
//
"use strict";
-var logger = require("logger");
var browser = require("tab-browser");
var self = require("self");
var Request = require("request").Request;
-var preferences = require("preferences-service");
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";
-
-var config = {};
+var libbz = require("libbugzilla");
function isOurPage(window, matchingURLs) {
var url = window.location.href;
@@ -48,66 +41,6 @@ function skipThisPage(doc) {
}
}
-function initialize(callback) {
- var prefName = BTSPrefNS+"JSONURL";
- var urlStr = "";
-
- if (preferences.isSet(prefName)) {
- urlStr = preferences.get(prefName);
- } else {
- urlStr = JSONURLDefault;
- preferences.set(prefName, JSONURLDefault);
- }
-
- // Randomize URL to avoid caching
- // TODO see https://fedorahosted.org/bugzilla-triage-scripts/ticket/21
- // for more thorough discussion and possible further improvement
- urlStr += (urlStr.match(/\?/) == null ? "?" : "&") + (new Date()).getTime();
-
- Request({
- url: urlStr,
- onComplete: function (response) {
- if (response.status == 200) {
- config.gJSONData = response.json;
-
- // Get additional tables
- if ("downloadJSON" in config.gJSONData.configData) {
- var URLsList = config.gJSONData.configData.downloadJSON;
- var dwnldObj = "";
- URLsList.forEach(function (arr) {
- var title = arr[0];
- var url = arr[1];
- Request({
- url: url,
- onComplete: function(response) {
- if (response.status == 200) {
- config.gJSONData.constantData[title] = response.json;
- }
- }
- }).get();
- }, this);
- }
-
- 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) {
- return x.replace("show_bug.cgi.*","((process|post)_bug|attachment)\.cgi$");
- });
-
- config.objConstructor = {};
- var bzType = config.gJSONData.configData.objectStyle;
- if (bzType === "RH") {
- config.objConstructor = require("rhbzpage").RHBugzillaPage;
- } else if (bzType === "MoFo") {
- config.objConstructor = require("mozillabzpage").MozillaBugzilla;
- }
-
- callback(config);
- }
- }
- }).get();
-}
/*
exports.main = function main(options, callbacks) {
@@ -141,28 +74,25 @@ var messageHandler = exports.messageHandler = function messageHandler(worker, ms
case "LogMessage":
console.log(msg.data);
break;
- case "GetDuplicatorID":
- getDuplicatorID(msg.data.host, msg.data.bugID, function (msgObj) {
- worker.postMessage(msgObj);
+ case "ExecCmd":
+ libbz.executeCommand(msg.data);
+ break;
+ case "GetInstalledPackages":
+ // send message with packages back
+ libbz.getInstalledPackages(msg.data, function (pkgsMsg) {
+ worker.postMessage(pkgsMsg);
});
break;
- case "GetPassword":
- getPassword(msg.data.login, msg.data.hostname, function (pass) {
- worker.postMessage(pass);
+ case "GetClipboard":
+ libbz.getClipboard(msg.data, function (clipboard) {
+ worker.postMessage(clipboard);
});
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();
+ case "ChangeJSONURL":
+ libbz.changeJSONURL();
+ break;
+ case "OpenURLinNewTab":
+ libbz.openURLinNewTab(msg.data);
break;
case "testReady":
// we ignore it here, interesting only in unit test
@@ -174,6 +104,8 @@ var messageHandler = exports.messageHandler = function messageHandler(worker, ms
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")
]