meatloaf-config/public/ws.html
Jaime Idolpx d7076f12da Add new assets and error handling pages
- Added various icon images (128x128, 16x16, 32x32, 48x48, 64x64, 76x76 PNGs).
- Introduced logo images in JPG and PNG formats, along with an SVG version.
- Created device XML file for UPnP compatibility.
- Implemented custom 404 and 405 error pages with a Commodore 64 theme.
- Added an SVG graphic for server error representation.
- Developed CSS styles for error pages to enhance visual appeal.
- Included a favicon cursor icon.
- Added a font file for "Microgramma D Extended Bold".
- Created a WebSocket test page with interactive command execution.
2026-06-08 12:03:03 -04:00

141 lines
3.6 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>ESP32 Web Server</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="data:,">
<style>
html {
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
h1 {
font-size: 1.8rem;
color: white;
}
h2 {
font-size: 1.5rem;
font-weight: bold;
color: #07156d;
}
.card {
background-color: #F8F7F9;
;
box-shadow: 2px 2px 12px 1px rgba(140, 140, 140, .5);
padding-top: 10px;
padding-bottom: 20px;
}
.card input {
width: 80%;
height: 2em;
font-size: 24px;
text-align: center;
}
.topnav {
overflow: hidden;
background-color: #4d4d4d;
}
.topnav img {
height: 100px;
}
body {
margin: 0;
}
.content {
padding: 30px;
max-width: 600px;
margin: 0 auto;
}
.button {
padding: 15px 50px;
font-size: 24px;
text-align: center;
outline: none;
color: #fff;
background-color: #0ffa6d; //green
border: #0ffa6d;
border-radius: 5px;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.button:active {
background-color: #fa0f0f;
transform: translateY(2px);
}
.state {
font-size: 1.5rem;
color: #120707;
font-weight: bold;
}
</style>
<title>Meatloaf WebSocket Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="data:,">
</head>
<body>
<div class="topnav">
<img src="assets/logo.svg" />
<h1>WebSocket Test</h1>
</div>
<div class="content">
<div class="card">
<h2>COMMAND</h2>
<input id="command" type="text"/>
<p><button id="button" class="button">Execute</button></p>
</div>
</div>
</div>
<script>
var gateway = `ws://${window.location.hostname}/ws`;
var websocket;
window.addEventListener('load', onLoad);
function initWebSocket() {
console.log('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');
}
function onClose(event) {
console.log('Connection closed');
setTimeout(initWebSocket, 2000);
}
function onMessage(event) {
var state;
console.log(event.data);
}
function onLoad(event) {
initWebSocket();
initButton();
}
function initButton() {
document.getElementById('button').addEventListener('click', execute);
}
function execute() {
var command = document.getElementById('command').value;
console.log(command);
websocket.send(command);
}
</script>
</body>
</html>