From 35067b1111ec50471e670eb0d264ca29d9f66692 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sun, 20 Feb 2011 03:23:27 +0100 Subject: Most of logger recovered. --- lib/logger.js | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) (limited to 'lib/logger.js') diff --git a/lib/logger.js b/lib/logger.js index 2b2277a..faceca2 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -9,6 +9,7 @@ var prompts = require("prompts"); var apiUtils = require("api-utils"); var xrpc = require("xmlrpc"); var myStorage = require("simple-storage"); +var libbz = require("libbugzilla"); var EmptyLogsColor = "rgb(0, 255, 0)"; var FullLogsColor = "rgb(0, 40, 103)"; @@ -70,17 +71,19 @@ function getBugzillaAbbr(url) { } exports.generateTimeSheet = function generateTimeSheet() { - // Logger.prototype.generateTimeSheet = function(body) { - // var doc = body.ownerDocument; - // this.timeSheetRecordsPrinter(body, myStorage.storage.logs); + var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs); + libbz.openURLInNewTab("data:text/html;charset=utf-8," + docHTML); }; -function timeSheetRecordsPrinter(body, records) { +function timeSheetRecordsPrinter(records) { var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)","g"); // sort the records into temporary array var tmpArr = []; + var outStr = '' + + "Status report" + + "

TimeSheet

\n"; - for ( var i in records) { + for (var i in records) { if (records.hasOwnProperty(i)) { tmpArr.push( [ i, records[i] ]); } @@ -99,38 +102,20 @@ function timeSheetRecordsPrinter(body, records) { var bugNo = utilMod.getBugNo(x.url); if (dayStr != currentDay) { currentDay = dayStr; - body.innerHTML += "

" + currentDay - + "

"; + outStr += "

" + currentDay + + "

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

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

"; - }); -} - -/** - * - */ -function createBlankPage(ttl, bodyBuildCB) { - var title = ttl || "Yet another untitled page"; - var that = this; - - var logTab = tabs.open({ - url: "about:blank", - inBackground: true, - onOpen: function (tab) { - var otherDoc = tab.contentDocument; - otherDoc.title = title; - otherDoc.body.innerHTML = "

" + title + "

"; - bodyBuildCB.call(that, otherDoc.body); - tabs.activeTab = tab; - } + + " \n
" + comment + "

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