aboutsummaryrefslogtreecommitdiffstats
path: root/lib/logger.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-02-01 17:16:43 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-02-01 17:16:43 +0100
commitcc50408c9661d35a81f921ff6347eee3c1781d0f (patch)
tree6219eeb70d7ce908b4786822d3f3abd2469b6391 /lib/logger.js
parentc1ec772b104316530f6737340355205398df33af (diff)
downloadbugzilla-triage-cc50408c9661d35a81f921ff6347eee3c1781d0f.tar.gz
Bit of cleaning of logger
Diffstat (limited to 'lib/logger.js')
-rw-r--r--lib/logger.js92
1 files changed, 36 insertions, 56 deletions
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);
-};
+}