### Placeholder Rust example Source: https://github.com/aoe2ct/aoe2rec/blob/main/crates/aoe2rec/README.md A placeholder Rust example marked as TODO. The actual code is not provided on this page. ```rust ``` -------------------------------- ### HTML file input for selecting a replay file Source: https://github.com/aoe2ct/aoe2rec/blob/main/crates/aoe2rec-js/README.md Provides a file input element with id 'fileElem' used to select a save game file for parsing. ```html ``` -------------------------------- ### Add aoe2rec dependency to Cargo.toml Source: https://github.com/aoe2ct/aoe2rec/blob/main/crates/aoe2rec/README.md Add this to your Cargo.toml to depend on the aoe2rec crate version 0.1. ```toml [dependencies] aoe2rec = "0.1" ``` -------------------------------- ### JavaScript: parse a selected file with parse_rec Source: https://github.com/aoe2ct/aoe2rec/blob/main/crates/aoe2rec-js/README.md Imports parse_rec from 'aoe2rec-js', listens for file selection, reads the file as an ArrayBuffer, and calls parse_rec. Errors are caught because not all recs are guaranteed to parse correctly. ```javascript import { parse_rec } from "aoe2rec-js"; const fileElem = document.getElementById("fileElem"); fileElem.addEventListener("change", event => { const files = (event.target as HTMLInputElement).files if (!files) { replayFile.value = null return } const file = files[0] const reader = new FileReader(); reader.addEventListener('loadend', (event) => { try { const rec = parse_rec(event.target.result); } catch (error) { // It's important to catch errors because not all recs are guaranteed to parse correctly console.error("Failed to parse game"); }; }, false); reader.readAsArrayBuffer(file); }, false); ```