SameBoy/wasm/web/index.html

60 lines
1.1 KiB
HTML
Raw Normal View History

2019-06-05 00:26:31 +00:00
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SameBoy</title>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
var Module = {
canvas: document.querySelector('#canvas')
};
</script>
2019-06-05 00:26:31 +00:00
<script src="SameBoy.js"></script>
<script>
const loadROM = f => {
const reader = new FileReader();
reader.onload = (file => {
return e => {
Module.load_rom(romName, e.target.result);
};
})(f);
reader.readAsArrayBuffer(f);
}
const handleFileSelect = (evt, files) => {
evt.stopPropagation();
evt.preventDefault();
if (files.length) {
load_rom(files[0]);
}
}
const handleDragOver = evt => {
evt.stopPropagation();
evt.preventDefault();
evt.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}
window.addEventListener('dragover', handleDragOver, false);
window.addEventListener('drop', e => {
handleFileSelect(e, e.dataTransfer.files);
}, false);
document.getElementById('file').addEventListener('change', e => {
handleFileSelect(e, e.target.files);
}, false);
2019-06-05 00:26:31 +00:00
Module.onRuntimeInitialized = _ => {
console.log(Module)
};
</script>
</body>
</html>