-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from maebli/feature/wasm-pack
Feature/wasm pack
- Loading branch information
Showing
20 changed files
with
699 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<!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: 600px; | ||
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; | ||
} | ||
|
||
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: 600px; | ||
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>Wired M-Bus Parser with WASM</h1> | ||
</div> | ||
<form> | ||
<label for="inputstring">Input String:</label> | ||
<textarea rows="5" cols="80" id="inputstring"></textarea> | ||
<input id="m_bus_parse" type="button" value="Parse JSON" /> | ||
</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(); // Ensure the WASM module is initialized | ||
|
||
document.getElementById('m_bus_parse').addEventListener('click', () => { | ||
const inputString = document.getElementById('inputstring').value; | ||
const result = m_bus_parse(inputString); | ||
const formattedResult = JSON.stringify(JSON.parse(result), null, 2); // Pretty-print the JSON | ||
const outputElement = document.getElementById("output"); | ||
outputElement.textContent = formattedResult; | ||
hljs.highlightElement(outputElement); // Apply syntax highlighting | ||
}); | ||
} | ||
|
||
setup(); // Set up the event listeners after the page is loaded | ||
</script> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.