Marlin 2.0 for Flying Bear 4S/5
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
684 B

document.addEventListener('DOMContentLoaded', () => {
const ws = new WebSocket(`ws://${location.host}/ws`);
ws.onmessage = (e) => {
if (typeof e.data === 'string') {
let node = document.createElement('li');
let text = document.createTextNode(e.data);
node.appendChild(text);
document.getElementById('serial-output').appendChild(node);
}
};
document.getElementById('serial-command-form').addEventListener('submit', (e) => {
e.preventDefault();
let value = document.getElementById('serial-command').value.trim();
if (!value) return;
ws.send(`${value}\n`);
document.getElementById('serial-command').value = '';
});
});