aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libbugzilla.js6
-rw-r--r--lib/logger.js92
2 files changed, 39 insertions, 59 deletions
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index 1c5f7a2..0477c70 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;
var selfMod = require("self");
@@ -278,8 +278,8 @@ exports.initialize = function initialize(config, callback) {
if ("submitsLogging" in config.gJSONData.configData &&
config.gJSONData.configData.submitsLogging) {
- // config.log = config.logger;
- // FIXME this.setUpLogging();
+ logger.initialize(JSON.parse(selfMod.data.load(
+ "bugzillalabelAbbreviations.json")));
}
}
callback();
diff --git a/lib/logger.js b/lib/logger.js
index 659faac..2b2277a 100644
--- a/lib/logger.js
+++ b/lib/logger.js
@@ -10,60 +10,45 @@ var apiUtils = require("api-utils");
var xrpc = require("xmlrpc");
var myStorage = require("simple-storage");
-exports.addLogRecord = function addLogRecord(rec) {
- if (myStorage.storage.logs[rec.key]) {
- myStorage.storage.logs[rec.key].comment += "<br/>\n" + comment;
- } else {
- myStorage.storage.logs[rec.key] = rec;
- }
-};
+var EmptyLogsColor = "rgb(0, 255, 0)";
+var FullLogsColor = "rgb(0, 40, 103)";
-exports.generateTimeSheet = function generateTimeSheet() {
- ; // FIXME
-};
-
-exports.clearTimeSheet = function clearTimeSheet() {
- ; // FIXME
-};
-
-exports.importTimeSheet = function importTimeSheet() {
- ; /* FIXME
- jsonPaths = prompts.promptFileOpenPicker(that.win);
- that.log.importOtherStore(jsonPaths, clearLogAElem);
- */
-};
-
-var Logger = exports.Logger = function Logger(abbsMap) {
- this.EmptyLogsColor = rgb(0, 255, 0);
- this.FullLogsColor = rgb(0, 40, 103);
+var abbsMap = {};
+exports.initialize = function initialize(aMap) {
if (!myStorage.storage.logs) {
myStorage.storage.logs = {};
}
+ abbsMap = aMap;
+};
- this.abbsMap = abbsMap;
+exports.addLogRecord = function addLogRecord(rec) {
+ if (myStorage.storage.logs[rec.key]) {
+ myStorage.storage.logs[rec.key].comment += "<br/>\n" + comment;
+ } else {
+ myStorage.storage.logs[rec.key] = rec;
+ }
};
-Logger.prototype.size = function size() {
+function storeSize() {
var size = 0, key;
for (key in myStorage.storage.logs) {
size++;
}
return size;
-};
+}
-Logger.prototype.isEmpty = function isEmpty() {
- return (this.size() === 0);
-};
+function isEmpty() {
+ return (storeSize() === 0);
+}
-Logger.prototype.clearStore = function clearStore(clearLink) {
+exports.clearTimeSheet = function clearTimeSheet() {
myStorage.storage.logs = {};
- var size = this.size();
- clearLink.style.color = this.EmptyLogsColor;
- clearLink.style.fontWeight = "normal";
+ var size = storeSize();
};
-Logger.prototype.importOtherStore = function importOtherStore (filename, clearLink) {
+exports.importTimeSheet = function importTimeSheet() {
+ var filename = prompts.promptFileOpenPicker(that.win);
if (fileMod.exists(filename)) {
var otherTS = JSON.parse(fileMod.read(filename));
if (otherTS.logs) {
@@ -76,21 +61,21 @@ Logger.prototype.importOtherStore = function importOtherStore (filename, clearLi
} else {
console.error("File " + filename + " doesn't exist!");
}
- if (this.size() > 0) {
- clearLink.style.color = this.FullLogsColor;
- clearLink.style.fontWeight = "bolder";
- }
};
-Logger.prototype.getBugzillaAbbr = function(url) {
+function getBugzillaAbbr(url) {
// for https://bugzilla.redhat.com/show_bug.cgi?id=579123 get RH
// for https://bugzilla.mozilla.org/show_bug.cgi?id=579123 get MoFo
- var abbr = this.abbsMap[urlMod.URL(url).host];
- return abbr;
-};
+ return abbsMap[urlMod.URL(url).host];
+}
-Logger.prototype.timeSheetRecordsPrinter = function(body, records) {
- var that = this;
+exports.generateTimeSheet = function generateTimeSheet() {
+ // Logger.prototype.generateTimeSheet = function(body) {
+ // var doc = body.ownerDocument;
+ // this.timeSheetRecordsPrinter(body, myStorage.storage.logs);
+};
+
+function timeSheetRecordsPrinter(body, records) {
var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)","g");
// sort the records into temporary array
var tmpArr = [];
@@ -110,7 +95,7 @@ Logger.prototype.timeSheetRecordsPrinter = function(body, records) {
var x = rec[1];
var dayStr = utilMod.getISODate(x.date);
var host = urlMod.URL(x.url).host;
- var BZName = that.getBugzillaAbbr(x.url);
+ var BZName = getBugzillaAbbr(x.url);
var bugNo = utilMod.getBugNo(x.url);
if (dayStr != currentDay) {
currentDay = dayStr;
@@ -127,13 +112,13 @@ Logger.prototype.timeSheetRecordsPrinter = function(body, records) {
+ x.title
+ "</a>"
+ " </em>\n<br/>" + comment + "</p>";
- });
- };
+ });
+}
/**
*
*/
-Logger.prototype.createBlankPage = function (ttl, bodyBuildCB) {
+function createBlankPage(ttl, bodyBuildCB) {
var title = ttl || "Yet another untitled page";
var that = this;
@@ -148,9 +133,4 @@ Logger.prototype.createBlankPage = function (ttl, bodyBuildCB) {
tabs.activeTab = tab;
}
});
-};
-
-Logger.prototype.generateTimeSheet = function(body) {
- var doc = body.ownerDocument;
- this.timeSheetRecordsPrinter(body, myStorage.storage.logs);
-};
+}