aboutsummaryrefslogtreecommitdiffstats
path: root/lib/main.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-06-08 18:41:08 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-06-08 18:41:08 +0200
commit7e426ac5faeea1b06de1ae2a024feaddb7f00531 (patch)
treef0e613f4a50c87efa7fa37c5bd284e1e6b9ee458 /lib/main.js
parent94fe9a684db8182110109b6d3a8ef1bad1075a6b (diff)
downloadbugzilla-triage-7e426ac5faeea1b06de1ae2a024feaddb7f00531.tar.gz
First almost working version of main.js
Diffstat (limited to 'lib/main.js')
-rw-r--r--lib/main.js103
1 files changed, 49 insertions, 54 deletions
diff --git a/lib/main.js b/lib/main.js
index eca533e..1027d72 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -16,61 +16,26 @@ var util = require("util");
var logger = require("logger");
var file = require("file");
var myStorage = require("simple-storage").storage;
+var browser = require("tab-browser");
+const JSONURL = "http://matej.ceplovi.cz/progs/data/RH_Data-packages.json";
+var myStorage = require("simple-storage");
-var TriagedDistro = 13;
-var NumberOfFrames = 7;
-var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi";
-var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id=";
-
-// ==============================================================
-// https://wiki.mozilla.org/Labs/Jetpack/JEP/24
-var manifest = {
- settings : [
- {
- name : "BZpassword",
- type : "password",
- label : "Bugzilla password"
- },
- {
- name : "JSONURL",
- type : "text",
- label : "Configuration file URL",
- "default" : "http://mcepl.fedorapeople.org/scripts/BugZappers_data.json"
- },
- {
- name : "enabledPacks",
- type : "text",
- label : "comment packs which should be enabled",
- "default" : ""
- }
- ]
-};
-jetpack.future.import("storage.settings");
-
-
-// TODO we should have an array SpecialFlags instead of multiple Boolean
-// variables
-var logSubmits = false;
-var chipIDsGroupings = [];
-var AddrArray = [];
-var topRow = {};
-var bottomRow = {};
-
-// /////////////////////////////////////////////////////////////////////////////
-
-let config = {};
+var config = {};
config.matches = [
"https://bugzilla.redhat.com/show_bug.cgi",
"https://bugzilla.mozilla.org/show_bug.cgi"
];
-util.loadJSON(jetpack.storage.settings.JSONURL, function(parsedData) {
- config.gJSONData = parsedData;
+function initialize(callback) {
+ util.loadJSON(JSONURL, function(parsedData) {
+ config.gJSONData = parsedData;
// Get card translation table
- let keys = "";
- for (let key in config.gJSONData) {
+ var keys = "", key = "";
+ for (key in config.gJSONData) {
keys += key + " ";
}
+ console.log("loaded JSON object keys: " + keys);
+
if ("PCIIDsURL" in config.gJSONData.configData) {
util.loadJSON(config.gJSONData.configData.PCIIDsURL, function(response) {
config.PCI_ID_Array = response;
@@ -79,14 +44,44 @@ util.loadJSON(jetpack.storage.settings.JSONURL, function(parsedData) {
config.logger = new logger.Logger(myStorage.logs,
config.gJSONData.constantData.bugzillalabelAbbreviations);
+
+ callback(config);
+}, this);
+
+}
+
+function isOurPage(window, bugzillaPageModLocation) {
+ if ("window" in window) {
+ window = window.window;
+ }
- let callback = function(doc) {
- if (config.gJSONData.configData.objectStyle = "RH") {
- let curPage = new RHBugzillaPage(doc);
- } else if (config.gJSONData.configData.objectStyle = "MoFo") {
- let curPage = new MozillaBugzilla(doc);
+ if (window.location.protocol == "https:") {
+ // like ["name1": "url1", "name2":"url2"]
+ // FIXME the real name of bugzillaPageModLocation array
+ for (var loc in bugzillaPageModLocation) {
+ if (bugzillaPageModLocation[loc].test(window.location.href)) {
+ return true;
+ }
}
- };
+ }
+ // we haven't found a conforming bugzilla
+ return false;
+}
- jetpack.pageMods.add(callback, config);
-}, this); \ No newline at end of file
+exports.main = function main(options, callbacks) {
+ initialize(function (config) {
+ browser.whenContentLoaded(
+ function(window) {
+ if (isOurPage(window)) {
+ var curPage = {};
+ var mycallback = function(doc) {
+ if (config.gJSONData.configData.objectStyle = "RH") {
+ curPage = new require("rhbzpage").RHBugzillaPage(doc, config);
+ } else if (config.gJSONData.configData.objectStyle = "MoFo") {
+ curPage = new require("mozillabzpage").MozillaBugzilla(doc, config);
+ }
+ };
+ }
+ });
+ });
+}; \ No newline at end of file