-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathconfigworker.js
126 lines (101 loc) · 3.43 KB
/
configworker.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
123
124
125
126
import logger from "./logger.js";
import Worker from "./worker.js";
class Config {
constructor() {
this.brand = "Viki";
this.brandIcon = "";
this.title = "Viki - A simple Wiki page in Markdown from notebook of VNote";
this.favicon = "https://github.com/tamlok/viki/raw/master/resources/viki.ico";
this.footer = "";
// Whether show suffix in navigation panel.
this.showSuffix = false;
this.loadBeforeSearch = true;
this.fuzzySearch = false;
this.markdown = {
html: true,
breaks: false,
linkify: true,
typographer: false,
langPrefix: 'lang-',
imageCaption: true,
plantUMLServer: 'http://www.plantuml.com/plantuml',
plantUMLFormat: 'svg',
codeBlockLineNumber: false
};
}
readFromJson(p_jobj) {
if (typeof p_jobj.brand != "undefined") {
this.brand = p_jobj.brand;
}
if (typeof p_jobj.brand_icon != "undefined") {
this.brandIcon = p_jobj.brand_icon;
}
if (typeof p_jobj.title != "undefined") {
this.title = p_jobj.title;
}
if (typeof p_jobj.favicon != "undefined") {
this.favicon = p_jobj.favicon;
}
if (p_jobj.footer != null) {
this.footer = p_jobj.footer;
}
if (p_jobj.show_suffix != null) {
this.showSuffix = p_jobj.show_suffix;
}
if (p_jobj.load_before_search != null) {
this.loadBeforeSearch = p_jobj.load_before_search;
}
if (p_jobj.fuzzy_search != null) {
this.fuzzySearch = p_jobj.fuzzy_search;
}
if (p_jobj.markdown) {
let md = p_jobj.markdown;
if (typeof md.html != "undefined") {
this.markdown.html = md.html;
}
if (typeof md.breaks != "undefined") {
this.markdown.breaks = md.breaks;
}
if (typeof md.linkify != "undefined") {
this.markdown.linkify = md.linkify;
}
if (typeof md.typographer != "undefined") {
this.markdown.typographer = md.typographer;
}
if (typeof md.lang_prefix != "undefined") {
this.markdown.langPrefix = md.lang_prefix;
}
if (typeof md.image_caption != "undefined") {
this.markdown.imageCaption = md.image_caption;
}
if (typeof md.plantuml_server != "undefined") {
this.markdown.plantUMLServer = md.plantuml_server;
}
if (typeof md.plantuml_format != "undefined") {
this.markdown.plantUMLFormat = md.plantuml_format;
}
if (typeof md.code_block_line_number != "undefined") {
this.markdown.codeBlockLineNumber = md.code_block_line_number;
}
}
}
}
class ConfigWorker extends Worker {
constructor() {
super();
}
register(p_viki) {
super.register(p_viki);
logger.log("register ConfigWorker");
}
run() {
$.get("viki.json", (p_data) => {
let config = new Config();
config.readFromJson(p_data);
logger.log("config:", config);
this.viki.config = config;
this.viki.scheduleNext();
});
}
}
export { Config, ConfigWorker };