Skip to content

Commit

Permalink
play with creating new HTML component via WebAssembly
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitshur committed Jul 18, 2019
1 parent 8a6ef1e commit 3d5a82c
Show file tree
Hide file tree
Showing 6 changed files with 928 additions and 0 deletions.
30 changes: 30 additions & 0 deletions 264/_data/index.html
@@ -0,0 +1,30 @@
<html>
<head>
<meta name="viewport" content="width=device-width">
<link href="/-/fonts/fonts.css" rel="stylesheet" type="text/css">
<link href="/-/style.css" rel="stylesheet" type="text/css">
<script src="/-/wasm_exec.js"></script>
<script>
if (!WebAssembly.instantiateStreaming) { // polyfill for Safari :/
WebAssembly.instantiateStreaming = async (resp, importObject) => {
const source = await (await resp).arrayBuffer();
return await WebAssembly.instantiate(source, importObject);
};
}
const go = new Go();
WebAssembly.instantiateStreaming(fetch("/-/main.wasm"), go.importObject).then((result) => {
go.run(result.instance);
});
window.addEventListener('keydown', (event) => {
if (event.key !== '®') {
return;
}
WebAssembly.instantiateStreaming(fetch("/-/main.wasm"), go.importObject).then((result) => {
go.run(result.instance);
});
event.preventDefault();
});
</script>
</head>
<body></body>
</html>
28 changes: 28 additions & 0 deletions 264/_data/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3d5a82c

Please sign in to comment.