From 32af48e442a960b8c3f199f5ffad28a34590fcda Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 28 Apr 2011 13:28:55 +0200 Subject: Reformatting to MoFo coding style --- lib/logger.js | 82 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'lib/logger.js') 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 += "
\n" + rec.comment; + if (myStorage.storage.logs[rec.key] + && myStorage.storage.logs[rec.key].comment) { + myStorage.storage.logs[rec.key].comment += "
\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 = '' + - "\n"+ - "\n"+ - "TimeSheet-"+ dateStr + "\n\n\n" + - "

TimeSheet

\n"; + var dateStr = date.getFullYear() + "-" + + xrpc.leadingZero(date.getMonth() + 1) + "-" + + xrpc.leadingZero(date.getDate()); + var outStr = '' + "\n" + + "\n" + "TimeSheet-" + + dateStr + "\n\n\n" + + "

TimeSheet

\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 += "

" + currentDay - + "

\n"; - } - // replace "bug ####" with a hyperlink to the current bugzilla - var comment = x.comment.replace(commentBugRE, - "$&"); - outStr += "

Bug " - + BZName + "/" + bugNo + ": " - + x.title - + "" - + " \n
" + comment + "

\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 += "

" + currentDay + + "

\n"; + } + // replace "bug ####" with a hyperlink to the current bugzilla + var comment = x.comment.replace(commentBugRE, + "$&"); + outStr += "

Bug " + BZName + + "/" + bugNo + ": " + x.title + "" + + " \n
" + comment + "

\n"; }); outStr += ""; return outStr; -} +}; -- cgit