diff options
Diffstat (limited to 'lib/logger.js')
-rw-r--r-- | lib/logger.js | 43 |
1 files changed, 14 insertions, 29 deletions
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 = '<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">' + + "<html><head><title>Status report</title></head><body>" + + "<h1>TimeSheet</h1>\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 += "<hr/><p><strong>" + currentDay - + "</strong></p>"; + 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>"); - body.innerHTML += "<p><em><a href='" + outStr += "<p><em><a href='" + x.url + "'>Bug " + BZName + "/" + bugNo + ": " + x.title + "</a>" - + " </em>\n<br/>" + comment + "</p>"; - }); -} - -/** - * - */ -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 = "<h1>" + title + "</h1>"; - bodyBuildCB.call(that, otherDoc.body); - tabs.activeTab = tab; - } + + " </em>\n<br/>" + comment + "</p>\n"; }); + outStr += "</body></html>"; + return outStr; } |