Add ESP32 WiFi interface (#11209)
This commit is contained in:
committed by
Scott Lahteine
parent
c03df89921
commit
0278ad0a6d
24
data/www/marlin.js
Normal file
24
data/www/marlin.js
Normal file
@ -0,0 +1,24 @@
|
||||
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 = '';
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user