<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Wired M-Bus Parser</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.0/languages/json.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #ffffff;
}
.header {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20px;
}
.header img {
margin-right: 10px;
}
h1 {
color: #333;
margin: 0;
}
form {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
max-width: 1100px;
margin: 0 auto;
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
}
textarea {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
margin-bottom: 10px;
font-family: monospace;
}
input[type="button"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
margin-right: 10px;
}
input[type="button"]:hover {
background-color: #45a049;
}
pre {
background: #f0f0f0;
padding: 10px;
border-radius: 4px;
white-space: pre-wrap;
word-wrap: break-word;
}
#output {
margin-top: 20px;
max-width: 1100px;
margin: 20px auto 0;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body>
<div class="header">
<img id="banner" src="meter.png" alt="Meter Banner">
<h1> Online M-Bus parser (wired) <i>https://maebli.github.io/m-bus-parser</i></h1>
</div>
<form>
<label for="inputstring">Input String:</label>
<textarea rows="5" cols="80"
id="inputstring">68 3D 3D 68 08 01 72 00 51 20 02 82 4D 02 04 00 88 00 00 04 07 00 00 00 00 0C 15 03 00 00 00 0B 2E 00 00 00 0B 3B 00 00 00 0A 5A 88 12 0A 5E 16 05 0B 61 23 77 00 02 6C 8C 11 02 27 37 0D 0F 60 00 67 16</textarea>
<input id="parse_json" type="button" value="Parse to JSON" />
<input id="parse_yaml" type="button" value="Parse to YAML" />
<input id="parse_table" type="button" value="Parse to Table" />
</form>
<pre id="output"></pre>
<script type="module">
import init, { m_bus_parse } from "./m_bus_parser_wasm_pack.js";
async function setup() {
await init();
document.getElementById('parse_json').addEventListener('click', () => {
parseInput("json");
});
document.getElementById('parse_yaml').addEventListener('click', () => {
parseInput("yaml");
});
document.getElementById('parse_table').addEventListener('click', () => {
parseInput("table_format");
});
function parseInput(format) {
const inputString = document.getElementById('inputstring').value;
const formattedResult = m_bus_parse(inputString, format);
const outputElement = document.getElementById("output");
outputElement.textContent = formattedResult;
}
}
setup(); </script>
</body>
</html>