blob: 80014d3a75ca10b2c01f9887d640f34e52f5275a (
plain)
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
|
//environment passed in from server
let env = window.env;
//the application config. default values here which can be overridden by user's local storage
let cfg = {
};
//some placeholder values here. some ideas for placeholder values here. might all be useful
let dom = {
input: {},
label: {},
box: {}, //an info-containing box
icon: {},
info: {}
};
//APP START HERE
$(document).ready(async function() {
// 1. setup relationship with DOM and grab references to its elements
log('init DOM');
await initDOM();
// 2. grab any local user config
log('init cfg');
await initCfg();
// 3. communicate with any external services if needed, like REST API or websocket
log('init services');
await initServices();
});
//gets user config from local storage if there is any
function initCfg(){
let localCfg = localStorage.getItem('config');
if (localCfg) {
try {
cfg = JSON.parse(localCfg);
} catch (e) {
cfg = {};
}
} else {
}
}
function initServices(){
//connect to websocket server
//grab data from REST API
}
function initDOM(){
dom.body = $('body')[0];
}
function log(msg, lvl=1){
if (dom.debugInfo){
dom.debugInfo.innerHTML = msg; //TODO running log + timestamp
}
console.log(msg);
}
|