-
Notifications
You must be signed in to change notification settings - Fork 32
/
status.html
66 lines (62 loc) · 1.91 KB
/
status.html
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
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<link rel=stylesheet href='style/ride-base.css'>
<link rel=stylesheet class=theme id=theme_dark href='style/dark-theme.css'>
<link rel=stylesheet class=theme id=theme_light href='style/light-theme.css'>
<script>
const ipc = require('node-ipc').default;
const el = require('@electron/remote');
const bw = el.getCurrentWindow();
const [width] = bw.getContentSize();
const qp = require('querystring').parse(window.location.search.slice(1));
const iswin = /^win/i.test(process.platform);
ipc.config.id = 'statusWin';
ipc.config.appspace = qp.appid;
ipc.config.retry = 1500;
ipc.config.silent = true;
let rm;
ipc.connectTo('ride_master', () => {
rm = ipc.of.ride_master;
rm.on('connect', () => {
window.onbeforeunload = (e) => {
e.returnValue = false;
rm.emit('statClose');
};
rm.emit('statCreated');
});
rm.on('disconnect', () => {
ipc.log('disconnected from ride_master'.notice);
window.onbeforeunload = null;
window.close();
});
// rm.on('add', (x) => add(x));
rm.on('add', add);
rm.on('setTheme', (theme) => {
document.getElementById('theme_dark').disabled = theme !== 'dark';
document.getElementById('theme_light').disabled = theme !== 'light';
});
rm.on('caption', (caption) => {
document.title =`Status Output - ${caption}`;
});
});
window.onkeydown=function(x) {
if (x.which===27) rm.emit('statClose');
}
const d = document;
function add(x) {
const b = d.body;
const s = d.getElementById('status');
const e = d.createElement('div');
e.className = 'm t' + x.flags;
e.textContent = x.text;
s.appendChild(e);
b.scrollTop = b.scrollHeight;
}
</script>
</head>
<body id=status_body>
<div id=status></div>
</body>
</html>