blob: cafef327b03cbca65d178972d26fefde4a67513a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
"use strict";
var fileMod = require("file");
var prompts = require("prompts");
var myStorage = require("simple-storage");
var EmptyLogsColor = "rgb(0, 255, 0)";
var FullLogsColor = "rgb(0, 40, 103)";
var abbsMap = {};
exports.initialize = function initialize() {
if (!myStorage.storage.logs) {
myStorage.storage.logs = {};
}
};
exports.addLogRecord = function addLogRecord(rec) {
if (myStorage.storage.logs[rec.key]
&& myStorage.storage.logs[rec.key].comment) {
myStorage.storage.logs[rec.key].comment += "<br/>\n"
+ rec.comment;
}
else {
myStorage.storage.logs[rec.key] = rec;
}
};
exports.getAllRecords = function getAllRecords() {
return myStorage.storage.logs;
};
exports.clearTimeSheet = function clearTimeSheet() {
myStorage.storage.logs = {};
};
exports.importTimeSheet = function importTimeSheet() {
var filename = prompts.promptFileOpenPicker();
if (fileMod.exists(filename)) {
var otherTS = JSON.parse(fileMod.read(filename));
if (otherTS.logs) {
for ( var rec in otherTS.logs) {
myStorage.storage.logs[rec] = otherTS.logs[rec];
}
}
else {
console.error("This is not a log file!");
}
}
else {
console.error("File " + filename + " doesn't exist!");
}
};
|