docs: update info about WASM web-demo example

This commit is contained in:
rzmk 2024-06-20 17:11:28 -04:00
parent 0648673c46
commit 9bd3090545
No known key found for this signature in database
7 changed files with 11 additions and 3 deletions

View file

@ -1,34 +0,0 @@
const progress = document.getElementById("progress");
import init, * as czv from "../../pkg/czv.js";
// Must run `await init()` or `initSync()` first for web use
await init();
const fileReader = new FileReader();
fileReader.onloadstart = () => {
if (progress) progress.style.display = "block";
};
fileReader.onloadend = () => {
const rowCountElement = document.getElementById("row-count");
const columnCountElement = document.getElementById("column-count");
if (rowCountElement)
rowCountElement.innerText = String(
czv.rowCount({
file_data: fileReader.result as string,
})
);
if (columnCountElement)
columnCountElement.innerText = String(
czv.columnCount({ file_data: fileReader.result as string })
);
if (progress) progress.style.display = "none";
};
const input = document.getElementById("upload");
if (input)
input.addEventListener("change", () => {
// @ts-ignore
fileReader.readAsText(input.files[0]);
});