mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-10 05:26:52 +03:00
66 lines
1.4 KiB
HTML
66 lines
1.4 KiB
HTML
<html>
|
|
<head>
|
|
<style>
|
|
#rx {
|
|
font-family: 'Courier New', Courier, monospace;
|
|
font-size: small;
|
|
}
|
|
</style>
|
|
<script type="text/javascript" src="common.js?v=$COMMIT_HASH"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="rx"></div>
|
|
|
|
|
|
<script>
|
|
var gateway = getDomainname().replace("http://", "ws://") + "/ws";
|
|
var websocket;
|
|
|
|
window.addEventListener('load', onLoad);
|
|
|
|
function initWebSocket() {
|
|
console.log('Trying to open a WebSocket connection...');
|
|
addToLog('Trying to open a WebSocket connection...');
|
|
|
|
websocket = new WebSocket(gateway);
|
|
websocket.onopen = onOpen;
|
|
websocket.onclose = onClose;
|
|
websocket.onmessage = onMessage; // <-- add this line
|
|
}
|
|
|
|
|
|
function onOpen(event) {
|
|
console.log('Connection opened');
|
|
addToLog('Connection opened');
|
|
}
|
|
|
|
|
|
function onClose(event) {
|
|
console.log('Connection closed');
|
|
addToLog('Connection closed');
|
|
setTimeout(initWebSocket, 2000);
|
|
}
|
|
|
|
|
|
function onMessage(event) {
|
|
console.log(event);
|
|
addToLog(event.data);
|
|
}
|
|
|
|
|
|
|
|
function onLoad(event) {
|
|
initWebSocket();
|
|
}
|
|
|
|
|
|
function addToLog(msg) {
|
|
document.getElementById('rx').innerHTML += "[" + new Date().toLocaleTimeString() + "] " +msg + "<br>\n";
|
|
window.scrollBy(0,document.body.scrollHeight);
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|