second commit
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,71 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<meta charset="utf-8">
|
||||
<title>Uart controller for esp32</title>
|
||||
<link rel="icon" href="favicon.ico" sizes="32x32">
|
||||
<style>
|
||||
:root {
|
||||
--bg: #222;
|
||||
--panel: #14171b;
|
||||
--danger: #ff3b30;
|
||||
--text: #e6eef6;
|
||||
}
|
||||
html, body {
|
||||
height:100%; margin:0;
|
||||
background:var(--bg);
|
||||
color:var(--text);
|
||||
font-family: Inter,system-ui, Segoe UI, Roboto, Helvetica,Arial;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
<header class="app-header"></header>
|
||||
<div class="content"></div>
|
||||
<footer class="footer"> <div class="error"></div></footer>
|
||||
</div>
|
||||
<script src="tools.js"></script>
|
||||
<script>
|
||||
let ws = null;
|
||||
const retryDelay = 1000; // 1 seconde
|
||||
|
||||
function sendCommand(payload) {
|
||||
try {
|
||||
if (!ws || ws.readyState !== WebSocket.OPEN)
|
||||
return;
|
||||
ws.send(JSON.stringify(payload));
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function connect() {
|
||||
ws = new WebSocket("ws://" + location.host + "/ws");
|
||||
|
||||
ws.onopen = () => {
|
||||
sendCommand({action: 'status'});
|
||||
};
|
||||
ws.onclose = (e) => {
|
||||
console.log("WS closed", e.code, e.reason);
|
||||
setTimeout(connect, retryDelay);
|
||||
};
|
||||
ws.onerror = (e) => {
|
||||
console.log("WS error", e);
|
||||
const data = JSON.parse(e.data);
|
||||
s('.error').textContent = data.error;
|
||||
ws.close();
|
||||
};
|
||||
ws.onmessage = (event) => {
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
//console.log("Réponse JSON : ", data);
|
||||
} catch (e) {
|
||||
//console.log("Message error: ", e);
|
||||
s('.error').textContent = e;
|
||||
}
|
||||
};
|
||||
}
|
||||
connect();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
** tools.js
|
||||
** GNU GENERAL PUBLIC LICENSE: (c) DD miraceti.net
|
||||
*/
|
||||
let s = function(sel) { return document.querySelector(sel); };
|
||||
let sId = function(sel) { return document.getElementById(sel); };
|
||||
let isJsonObject = function(value) { return value !== undefined && value !== null && typeof value === 'object'; }
|
||||
let to_date = function(unixtimestamp) { return new Date(parseInt(unixtimestamp)*1000).toLocaleString(); }
|
||||
Reference in New Issue
Block a user