aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-02-20 03:23:27 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-02-20 03:23:27 +0100
commit35067b1111ec50471e670eb0d264ca29d9f66692 (patch)
tree1340b038ac0330a4ab5e3627f8f59e926f40b5d1
parentbd116ff3ac5cc62bbd85ef7036bc64f3f14ce794 (diff)
downloadbugzilla-triage-35067b1111ec50471e670eb0d264ca29d9f66692.tar.gz
Most of logger recovered.
-rw-r--r--data/bzpage.js12
-rw-r--r--data/util.js3
-rw-r--r--lib/libbugzilla.js2
-rw-r--r--lib/logger.js43
4 files changed, 29 insertions, 31 deletions
diff --git a/data/bzpage.js b/data/bzpage.js
index 0d3bcbe..807793a 100644
--- a/data/bzpage.js
+++ b/data/bzpage.js
@@ -758,19 +758,24 @@ function getLogin () {
}
function addLogRecord() {
+ console.log("addLogRecord entered");
var rec = {};
rec.date = new Date();
rec.url = document.location.toString();
rec.title = document.title;
var comment = window.prompt(
"Enter comments for this comment");
+ console.log("window.prompt = " + window.prompt);
+ console.log("comment = " + comment);
if (comment && comment.length > 0) {
comment = comment.trim();
rec.comment = comment;
var dateStr = getISODate(rec.date);
var urlStr = window.location.hostname;
+ var bugNo = getBugNoFromURL(window.location.href);
rec.key = dateStr + "+" +
- urlStr + "+" + getBugNo();
+ urlStr + "+" + bugNo;
+ console.log("addLogRecord : rec = " + rec.toSource())
postMessage(new Message("AddLogRecord", rec));
return rec;
}
@@ -792,7 +797,10 @@ function setUpLogging () {
// logging all submits for timesheet
if (!submitHandlerInstalled) {
document.forms.namedItem("changeform").addEventListener("submit",function (evt) {
- if (addLogRecord() === null) {
+ console.log("addLogRecord = " + addLogRecord);
+ var logRecord = addLogRecord();
+ console.log("logRecord = " + logRecord.toSource());
+ if (logRecord === null) {
evt.stopPropagation();
evt.preventDefault();
}
diff --git a/data/util.js b/data/util.js
index 6c5e7b0..8232e9f 100644
--- a/data/util.js
+++ b/data/util.js
@@ -64,6 +64,7 @@ function parseXMLfromString (inStuff) {
* Get a bug no
*/
function getBugNo() {
+ console.log("bugNo = " + document.forms.namedItem('changeform').getElementsByName("id")[0].value);
return document.forms.namedItem('changeform').getElementsByName("id")[0].value;
}
@@ -73,7 +74,9 @@ function getBugNo() {
* @return String with the bug ID
*/
function getBugNoFromURL(url) {
+ console.log("getBugNoFromURL : url = " + url);
var params = parseURL(url).params;
+ console.log("getBugNoFromURL : params = " + params.toSource());
if (params && params.id) {
return params.id;
}
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index c13c61d..23b6869 100644
--- a/lib/libbugzilla.js
+++ b/lib/libbugzilla.js
@@ -372,6 +372,8 @@ exports.initialize = function initialize(config, callback) {
if ("submitsLogging" in config.gJSONData.configData &&
config.gJSONData.configData.submitsLogging) {
+ console.log("initialize : submitsLogin = " +
+ config.gJSONData.configData.submitsLogging);
logger.initialize(JSON.parse(selfMod.data.load(
"bugzillalabelAbbreviations.json")));
}
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;
}