Skip to content

Commit

Permalink
IPC interface and misc
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlTD committed Oct 29, 2021
1 parent feea125 commit 457da04
Showing 1 changed file with 54 additions and 5 deletions.
59 changes: 54 additions & 5 deletions status.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,61 @@
<head>
<meta charset=utf-8>
<link rel=stylesheet href='style/ride-base.css'>
<link rel=stylesheet href='style/light-theme'>
<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>
onkeydown=function(x){if(x.which===27)close()}
function add(x){var d=document,b=d.body,s=d.getElementById('status')
var e=d.createElement('div');e.className='m t'+x.flags;e.textContent=x.text
s.appendChild(e);b.scrollTop=b.scrollHeight}

const ipc = require('node-ipc');
const el = require('@electron/remote');
const bw = el.getCurrentWindow();
const [width] = bw.getSize();
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>
Expand Down

0 comments on commit 457da04

Please sign in to comment.