aboutsummaryrefslogtreecommitdiffstats
path: root/lib/logger.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/logger.js')
-rw-r--r--lib/logger.js82
1 files changed, 42 insertions, 40 deletions
diff --git a/lib/logger.js b/lib/logger.js
index ce96f69..ed9ac47 100644
--- a/lib/logger.js
+++ b/lib/logger.js
@@ -24,8 +24,10 @@ exports.initialize = function initialize(aMap) {
};
exports.addLogRecord = function addLogRecord(rec) {
- if (myStorage.storage.logs[rec.key] && myStorage.storage.logs[rec.key].comment) {
- myStorage.storage.logs[rec.key].comment += "<br/>\n" + rec.comment;
+ if (myStorage.storage.logs[rec.key]
+ && myStorage.storage.logs[rec.key].comment) {
+ myStorage.storage.logs[rec.key].comment += "<br/>\n"
+ + rec.comment;
}
else {
myStorage.storage.logs[rec.key] = rec;
@@ -54,7 +56,7 @@ exports.importTimeSheet = function importTimeSheet() {
if (fileMod.exists(filename)) {
var otherTS = JSON.parse(fileMod.read(filename));
if (otherTS.logs) {
- for (var rec in otherTS.logs) {
+ for ( var rec in otherTS.logs) {
myStorage.storage.logs[rec] = otherTS.logs[rec];
}
}
@@ -74,27 +76,30 @@ function getBugzillaAbbr(url) {
}
exports.generateTimeSheet = function generateTimeSheet() {
- var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs, new Date());
- libbz.openURLInNewTab("data:text/html;charset=utf-8," + docHTML);
-};
+ var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs,
+ new Date());
+ libbz.openURLInNewTab("data:text/html;charset=utf-8,"
+ + docHTML);
+};
-var timeSheetRecordsPrinter = exports.timeSheetRecordsPrinter =
- function timeSheetRecordsPrinter(records, date) {
- var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)","g");
+var timeSheetRecordsPrinter = exports.timeSheetRecordsPrinter = function timeSheetRecordsPrinter(
+ records, date) {
+ var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)", "g");
// sort the records into temporary array
var tmpArr = [];
- var dateStr = date.getFullYear() + "-" +
- xrpc.leadingZero(date.getMonth()+1) + "-" +
- xrpc.leadingZero(date.getDate());
- var outStr = '<!DOCTYPE html>' +
- "<html><head>\n"+
- "<meta charset='utf-8'/>\n"+
- "<title>TimeSheet-"+ dateStr + "</title>\n</head>\n<body>\n" +
- "<h1>TimeSheet</h1>\n";
+ var dateStr = date.getFullYear() + "-"
+ + xrpc.leadingZero(date.getMonth() + 1) + "-"
+ + xrpc.leadingZero(date.getDate());
+ var outStr = '<!DOCTYPE html>' + "<html><head>\n"
+ + "<meta charset='utf-8'/>\n" + "<title>TimeSheet-"
+ + dateStr + "</title>\n</head>\n<body>\n"
+ + "<h1>TimeSheet</h1>\n";
- for (var i in records) {
+ for ( var i in records) {
if (records.hasOwnProperty(i)) {
- tmpArr.push( [ i, records[i] ]);
+ tmpArr.push([
+ i, records[i]
+ ]);
}
}
tmpArr.sort(function(a, b) {
@@ -112,27 +117,24 @@ var timeSheetRecordsPrinter = exports.timeSheetRecordsPrinter =
var currentDay = "";
// now print the array
tmpArr.forEach(function(rec) {
- var x = rec[1];
- var dayStr = utilMod.getISODate(x.date);
- var host = urlMod.URL(x.url).host;
- var BZName = getBugzillaAbbr(x.url);
- var bugNo = utilMod.getBugNo(x.url);
- if (dayStr != currentDay) {
- currentDay = dayStr;
- outStr += "<hr/><p><strong>" + currentDay
- + "</strong></p>\n";
- }
- // replace "bug ####" with a hyperlink to the current bugzilla
- var comment = x.comment.replace(commentBugRE,
- "<a href='http://"+host+"/show_bug.cgi?id=$1'>$&</a>");
- outStr += "<p><em><a href='"
- + x.url
- + "'>Bug "
- + BZName + "/" + bugNo + ": "
- + x.title
- + "</a>"
- + " </em>\n<br/>" + comment + "</p>\n";
+ var x = rec[1];
+ var dayStr = utilMod.getISODate(x.date);
+ var host = urlMod.URL(x.url).host;
+ var BZName = getBugzillaAbbr(x.url);
+ var bugNo = utilMod.getBugNo(x.url);
+ if (dayStr != currentDay) {
+ currentDay = dayStr;
+ outStr += "<hr/><p><strong>" + currentDay
+ + "</strong></p>\n";
+ }
+ // replace "bug ####" with a hyperlink to the current bugzilla
+ var comment = x.comment.replace(commentBugRE,
+ "<a href='http://" + host
+ + "/show_bug.cgi?id=$1'>$&</a>");
+ outStr += "<p><em><a href='" + x.url + "'>Bug " + BZName
+ + "/" + bugNo + ": " + x.title + "</a>"
+ + " </em>\n<br/>" + comment + "</p>\n";
});
outStr += "</body></html>";
return outStr;
-}
+};