aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bzpage.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bzpage.js')
-rw-r--r--lib/bzpage.js29
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js
index 9276a2b..9c24256 100644
--- a/lib/bzpage.js
+++ b/lib/bzpage.js
@@ -6,6 +6,7 @@ var util = require("util");
var passUtils = require("passwords");
var apiUtils = require("api-utils");
var selfMod = require("self");
+var fileMod = require("file");
var simpleStorage = require("simple-storage");
var preferences = require("preferences-service");
var prompts = require("prompts");
@@ -781,7 +782,7 @@ BZPage.prototype.setUpLogging = function setUpLogging () {
var generateTimeSheetUI = this.doc.createElement("li");
generateTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='#' id='generateTSButton'>"
- + "Generate timesheet</a>";
+ + "Generate TS</a>";
additionalButtons.appendChild(generateTimeSheetUI);
this.doc.getElementById("generateTSButton").addEventListener(
"click",
@@ -792,9 +793,33 @@ BZPage.prototype.setUpLogging = function setUpLogging () {
evt.preventDefault();
}, false);
+ var ImportTimeSheetUI = this.doc.createElement("li");
+ ImportTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='#' id='importTSButton'>"
+ + "Import TS</a>";
+ additionalButtons.appendChild(ImportTimeSheetUI);
+ 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!");
+ }
+ }, false);
+
var clearLogsUI = this.doc.createElement("li");
clearLogsUI.innerHTML = "\u00A0-\u00A0<a href='#' id='clearLogs'>"
- + "Clear logs</a>";
+ + "Clear TS</a>";
additionalButtons.appendChild(clearLogsUI);
var clearLogAElem = this.doc.getElementById("clearLogs");
clearLogAElem.addEventListener("click", function() {