Skip to content

Commit

Permalink
deploy: 6a67ffc
Browse files Browse the repository at this point in the history
  • Loading branch information
VichoReyes committed May 5, 2024
0 parents commit bfbebbd
Show file tree
Hide file tree
Showing 4 changed files with 605 additions and 0 deletions.
Empty file added .nojekyll
Empty file.
51 changes: 51 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>WebAssembly</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
</head>
<body>
<label>
Select an image from your computer:
<input type="file" id="file" accept="image/*" />
</label>
<p id="loading">
Loading...
</p>
<button id="download" style="display: none;">Download</button>

<script src="wasm_exec.js"></script>
<script>
function downloadFile(blob, filename) {
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(url);
document.body.removeChild(a);
}
async function loadImage() {
const input = document.querySelector("#file");
if (input.files) {
const ab = await input.files[0].arrayBuffer();
const excel = convertToExcel(new Uint8Array(ab));
const blob = new Blob([excel], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
downloadFile(blob, "output.xlsx");
} else {
alert("Please select a file.");
}
}
const go = new Go();
WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then((result) => {
go.run(result.instance);
document.querySelector("#loading").style = "display: none";
document.querySelector("#download").style = "display: block";
});
document.querySelector("#download").addEventListener("click", loadImage);
</script>

</body>
</html>
Binary file added main.wasm
Binary file not shown.
Loading

0 comments on commit bfbebbd

Please sign in to comment.