aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-06-27 15:23:12 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-06-27 15:23:12 +0200
commit890dd7f9adcbe1ef7c4218edc89ee7075a12e211 (patch)
tree855893c690ebfbe5502b8151e3d3009501957091 /lib
parent955f77978ea6f3f5730571698de07cc77d1fc5a4 (diff)
downloadbugzilla-triage-890dd7f9adcbe1ef7c4218edc89ee7075a12e211.tar.gz
Move all constant data out of the main JSON
Diffstat (limited to 'lib')
-rw-r--r--lib/main.js40
-rw-r--r--lib/rhbzpage.js12
-rw-r--r--lib/xmlrpc.js2
3 files changed, 27 insertions, 27 deletions
diff --git a/lib/main.js b/lib/main.js
index f40dcd1..3d59d6e 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -16,6 +16,7 @@ var logger = require("logger");
var myStorage = require("simple-storage").storage;
var browser = require("tab-browser");
var urlMod = require("url");
+var selfMod = require("self");
var preferences = require("preferences-service");
var BSTPrefNS = require("bzpage").BSTPrefNS;
// Use my JSON for now before it is fixed for general public
@@ -26,21 +27,12 @@ var NumberOfFrames = 7;
var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi";
var config = {};
-config.matches = [
- "https://bugzilla.redhat.com/show_bug.cgi",
- "https://bz-web2-test.devel.redhat.com/show_bug.cgi",
- "https://bugs.freedesktop.org/show_bug.cgi",
- "https://bugzilla.mozilla.org/show_bug.cgi"
-];
-
-config.skipMatches = [
- "https://bugzilla.redhat.com/(process|post)_bug.cgi",
- "https://bz-web2-test.devel.redhat.com/(process|post)_bug.cgi",
- "https://bugzilla.mozilla.org/post_bug.cgi",
- "https://bugzilla.mozilla.org/process_bug.cgi",
- "https://bugzilla.(redhat.com|mozilla.org)/attachment.cgi$"
-];
-
+(function (){
+ var matchesAll = JSON.parse(selfMod.data.load("matches.json"));
+ config.matches = matchesAll.matches;
+ config.skipMatches = matchesAll.skipMatches;
+})();
+console.log("config.matches = " + config.matches.toSource());
// ==============================================================
// https://wiki.mozilla.org/Labs/Jetpack/JEP/24
var WillBemanifest = {
@@ -114,11 +106,17 @@ function initialize(callback) {
console.log("loaded JSON object keys: " + keys);
// Get card translation table
- if ("PCIIDsURL" in config.gJSONData.configData) {
- util.loadJSON(config.gJSONData.configData.PCIIDsURL, function(response) {
- config.PCI_ID_Array = response;
- });
- }
+ if ("downloadJSON" in config.gJSONData.configData) {
+ var URLsList = config.gJSONData.configData.downloadJSON;
+ for (var dwnldObj in URLsList) {
+ console.log("Downloading " +
+ dwnldObj + " from URL " +
+ URLsList[dwnldObj] + ".");
+ util.loadJSON(URLsList[dwnldObj],function(response){
+ config[dwnldObj] = response;
+ });
+ }
+ };
if (!myStorage.logs) {
console.log("myStorage.logs empty!");
@@ -127,7 +125,7 @@ function initialize(callback) {
var logConstructor = logger.Logger;
config.logger = new logConstructor(myStorage.logs,
- config.gJSONData.constantData.bugzillalabelAbbreviations);
+ JSON.parse(selfMod.data.load("bugzillalabelAbbreviations.json")));
callback(config);
}, this);
diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js
index ef28175..f61a88b 100644
--- a/lib/rhbzpage.js
+++ b/lib/rhbzpage.js
@@ -6,6 +6,7 @@ var util = require("util");
var xrpc = require("xmlrpc");
var apiUtils = require("api-utils");
var xhr = require("xhr");
+var self = require("self");
var clip = require("clipboard");
var Color = require("color").Color;
var BZPage = require("bzpage").BZPage;
@@ -410,7 +411,7 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) {
var that = this;
function groupIDs(manStr, cardStrID) {
- var outStr = util.filterByRegexp(chipIDsGroupings, manStr + "," + cardStrID);
+ var outStr = util.filterByRegexp(config.chipIDsGroupings, manStr + "," + cardStrID);
if (outStr.length === 0) {
outStr = "UNGROUPED_" + manStr + "/" + cardStrID;
}
@@ -597,7 +598,7 @@ RHBugzillaPage.prototype.queryUpstream = function() {
var text = this.getSelectionOrClipboard();
if (text) {
text = encodeURIComponent(text.trim());
- var queryUpstreamBugsURLArray = this.constantData.queryUpstreamBug;
+ var queryUpstreamBugsURLArray = self.data.load("queryUpstreamBug.json");
var urlBase = util.filterByRegexp(queryUpstreamBugsURLArray, this.component);
tabs.open({
url: urlBase + text,
@@ -614,7 +615,7 @@ RHBugzillaPage.prototype.queryUpstream = function() {
*/
RHBugzillaPage.prototype.sendBugUpstream = function() {
var that = this;
- var urlStr = util.filterByRegexp(this.constantData.newUpstreamBug, this
+ var urlStr = util.filterByRegexp(JSON.parse(self.data.load("newUpstreamBug.json")), this
.getOptionValue("component"));
var ret = tabs.open({
@@ -692,8 +693,9 @@ RHBugzillaPage.prototype.fixElement = function(elem, beforeText, accKey, afterTe
*/
RHBugzillaPage.prototype.getBugzillaName = function(URLhostname) {
var bugzillaID = "";
- if (this.constantData.bugzillalabelNames[URLhostname]) {
- bugzillaID = this.constantData.bugzillalabelNames[URLhostname];
+ var bzLabelNames = JSON.parse(self.data.load("bugzillalabelNames.json"));
+ if (bzLabelNames[URLhostname]) {
+ bugzillaID = bzLabelNames[URLhostname];
} else {
bugzillaID = "";
}
diff --git a/lib/xmlrpc.js b/lib/xmlrpc.js
index 7ae622c..9163089 100644
--- a/lib/xmlrpc.js
+++ b/lib/xmlrpc.js
@@ -1,4 +1,4 @@
-// Released under the MIT/X11 license
+// Modification of Matěj Cepl released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
"use strict";
/*