blob: 54aacc7d6879b6d7b9e5a772c050a742b4f7d415 (
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
66
67
68
69
70
71
72
73
74
75
|
//import { setupRenderSystem } from './render.js';
let ENVURL = "" //remote server from which to grab env
let env = {};
let cfg = {}; //the user config
let dom = {
input: {},
label: {},
box: {}, //an info-containing box
icon: {},
info: {}
};
//APP START HERE
$(document).ready(async function() {
console.log('asdf');
//the core loop of the client application
// 1. setup relationship with DOM and grab references to its elements
log('init DOM');
await initDOM();
log('init cfg');
await initCfg();
log('get env vars');
await getServerEnvVars();
log('init services');
await initServices();
//setupRenderSystem();
});
//gets user config from local storage if there is any
function initCfg(){
let localCfg = localStorage.getItem('cfg');
if (localCfg) {
try {
cfg = JSON.parse(localCfg);
} catch (e) {
cfg = {};
}
} else {
}
}
async function getServerEnvVars(){
await axios.get(`${ENVURL}`).then((res)=>{
env = res.data;
//log(env);
}).catch((err)=>{
//log(err);
});
log('')
}
function initServices(){
//connect to websocket server
//grab endpoints from cfg
}
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);
}
|