Files
esop/web/esop-web-app.js
T

30 lines
902 B
JavaScript

//app part not related to ESOP JS implementation
function main() {
var devCfg = {
audio: null,
canvas: document.getElementById('C') //JS-specific implementation canvas DOM reference
}
document.getElementById('apprun').addEventListener('click', function() {
var fileObj = document.getElementById('appselect').files[0]
if(fileObj.name.endsWith('.eso')) {
var rdr = new FileReader()
rdr.onload = function() {
var vm = UxnCore()
var ext = ESOPExtensions()
devCfg.audio = new (window.AudioContext || window.webkitAudioContext)
vm.boot()
ext.setup(vm, devCfg)
vm.load(new Uint8Array(rdr.result))
console.log('VM started')
vm.start(0x100)
}
rdr.readAsArrayBuffer(fileObj)
}
else window.alert('Please select an .eso file to run on ESOP')
})
}
addEventListener('DOMContentLoaded', main)