aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bzpage.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-09-24 12:28:11 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-09-24 12:28:11 +0200
commit4ffd6b9e6b61c9eaa323e4f4d537db5d1a36872d (patch)
tree542c7162a1924149e70a1e0004f4a221d48d4615 /lib/bzpage.js
parentf31ed4f55d9a33bb39a5e409b36878b5ac4ae470 (diff)
downloadbugzilla-triage-4ffd6b9e6b61c9eaa323e4f4d537db5d1a36872d.tar.gz
Fix Logger object to be self contained and use storage properly
* there is really no other way than using module.storage directly Sucks! * all logger-related logic should go to the module and not be flying around (import TS, clear, isEmpty)
Diffstat (limited to 'lib/bzpage.js')
-rw-r--r--lib/bzpage.js50
1 files changed, 17 insertions, 33 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js
index 269f4fa..2aeaf51 100644
--- a/lib/bzpage.js
+++ b/lib/bzpage.js
@@ -7,7 +7,6 @@ var passUtils = require("passwords");
var apiUtils = require("api-utils");
var selfMod = require("self");
var clip = require("clipboard");
-var fileMod = require("file");
var simpleStorage = require("simple-storage");
var preferences = require("preferences-service");
var selection = require("selection");
@@ -945,6 +944,18 @@ BZPage.prototype.setUpLogging = function setUpLogging () {
evt.preventDefault();
}, false);
+ var clearLogsUI = this.doc.createElement("li");
+ clearLogsUI.innerHTML = "\u00A0-\u00A0<a href='' id='clearLogs'>"
+ + "Clear TS</a>";
+ additionalButtons.appendChild(clearLogsUI);
+ var clearLogAElem = this.doc.getElementById("clearLogs");
+ clearLogAElem.addEventListener("click", function(evt) {
+ that.log.clearStore(this);
+ console.log("this.store wiped out!");
+ evt.stopPropagation();
+ evt.preventDefault();
+ }, false);
+
var ImportTimeSheetUI = this.doc.createElement("li");
ImportTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='' id='importTSButton'>"
+ "Import TS</a>";
@@ -952,45 +963,18 @@ BZPage.prototype.setUpLogging = function setUpLogging () {
this.doc.getElementById("importTSButton").addEventListener(
"click",
function(evt) {
- var otherTS = {}, thisTS = that.log.store;
-
jsonPaths = prompts.promptFileOpenPicker(that.win);
- if (fileMod.exists(jsonPaths)) {
- otherTS = JSON.parse(fileMod.read(jsonPaths));
- if (otherTS.logs) {
- for (var rec in otherTS.logs) {
- thisTS[rec] = otherTS.logs[rec];
- }
- } else {
- console.error("This is not a log file!");
- }
- } else {
- console.error("File " + jsonPaths + " doesn't exist!");
- }
+ that.log.importOtherStore(jsonPaths, clearLogAElem);
evt.stopPropagation();
evt.preventDefault();
}, false);
- var clearLogsUI = this.doc.createElement("li");
- clearLogsUI.innerHTML = "\u00A0-\u00A0<a href='' id='clearLogs'>"
- + "Clear TS</a>";
- additionalButtons.appendChild(clearLogsUI);
- var clearLogAElem = this.doc.getElementById("clearLogs");
- clearLogAElem.addEventListener("click", function() {
- that.log.store = {};
- this.style.color = that.log.EmptyLogsColor;
- this.style.fontWeight = "normal";
- console.log("this.store wiped out!");
- evt.stopPropagation();
- evt.preventDefault();
- }, false);
-
- if (this.log.store.length > 0) {
- clearLogAElem.style.color = this.log.FullLogsColor;
- clearLogAElem.style.fontWeight = "bolder";
- } else {
+ if (this.log.isEmpty()) {
clearLogAElem.style.color = this.log.EmptyLogsColor;
clearLogAElem.style.fontWeight = "normal";
+ } else {
+ clearLogAElem.style.color = this.log.FullLogsColor;
+ clearLogAElem.style.fontWeight = "bolder";
}
};