aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bzpage.js
diff options
context:
space:
mode:
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";
}
};