-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
123 lines (107 loc) · 3.43 KB
/
app.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
global.$ = $;
global.settings = {
author : ""
};
global.settings.alertMsg = window.alert;
var fs = require('fs');
var path = require('path');
var shell = require('nw.gui').Shell;
var step = require('step');
var Datastore = require('nedb');
var path = require('path');
var repoListDb = new Datastore({ filename: path.join(require('nw.gui').App.dataPath, 'list.db') });
var authorInfoDb = new Datastore({filename : path.join(require('nw.gui').App.dataPath, 'author.db') });
authorInfoDb.loadDatabase();
repoListDb.loadDatabase();
global.settings.authorInfoDb = authorInfoDb;
global.settings.repoListDb = repoListDb;
var sideEventLogic = require('./sideMenuEventLogic.js');
var utilLibs = require('./utils.js');
var eventTrigger = require('./eventTrigger.js');
var repositories = require('./repositories.js');
var logFetcher = require('./fetchGitLog.js');
var author = global.settings.author;
$(document).ready(function() {
//init setting
var jQuery = $;
triggerInitDbModalEvent(jQuery);
triggerEditAuthorInfoEvent(jQuery);
triggerEditAuthorInfoModalEvent(jQuery);
triggerInputAuthorInfoEvent(jQuery);
eventTrigger.sortByDate(jQuery);
eventTrigger.showAllBtn(jQuery);
eventTrigger.setDuration(jQuery);
jQuery("#about").on('click', function () {
alert("Not support yet\nContact to [email protected]\nhttps://github.com/jays1204/workinglog");
});
step(
function () {
loadAuthorInfo(jQuery, this);
},
function getRepoList(err, runLoadRepository) {
if (err) {
alert(err);
}
if (runLoadRepository === true) {
repositories.loadRepositoryList(jQuery, this);
} else {
return;
}
},
function done(err) {
if (err) {
alert(err);
}
}
);
eventTrigger.addRepository(jQuery);
});
function triggerInitDbEvent(jQuery) {
jQuery("#initConfigurationModal div.modal-footer button[type='submit']").on('click', function () {
sideMenuEventLogic.initDbOnSubmit();
});
}
function triggerInitDbModalEvent(jQuery) {
jQuery("#initConfigurationModal div.modal-footer button[data-dismiss='modal']").on('click', function () {
jQuery("#initConfigurationModal").modal('hide');
});
jQuery("#initDbBtn").on('click', function () {
jQuery("#initConfigurationModal").modal();
});
}
function triggerEditAuthorInfoEvent(jQuery) {
jQuery("#editInfoBtn").on('click', function () {
jQuery("#editAuthorInfoModal").modal();
});
}
function triggerInputAuthorInfoEvent(jQuery) {
jQuery("#inputAuthorInfoModal div.modal-footer button[type='submit']").on('click', function () {
var inputAuthorName = jQuery("#inputAuthorInfoModal div.modal-body form input").val();
sideMenuEventLogic.inputAuthorInfo(jQuery, inputAuthorName);
});
}
function triggerEditAuthorInfoModalEvent(jQuery) {
jQuery("#editAuthorInfoModal div.modal-footer button[type='submit']").on('click', function () {
sideMenuEventLogic.editAuthorInfoOnSubmit(jQuery);
});
}
//
function loadAuthorInfo(jQuery, callback) {
step(
function getAuthorInfo() {
authorInfoDb.findOne({'author' : true}, this);
}, function (err, doc) {
if (err) {
return callback(err);
}
if (doc === null) {
jQuery("#inputAuthorInfoModal").modal();
return callback(null, false);
} else {
author = doc.authorName;
global.settings.author = author;
return callback(null, true);
}
}
);
}