esop-web-app.js (880B)
1 //app part not related to ESOP JS implementation 2 3 function main() { 4 var devCfg = { 5 audio: null, 6 canvas: document.getElementById('C') //JS-specific implementation canvas DOM reference 7 }, vm = UxnCore(), ext = ESOPExtensions() 8 9 document.getElementById('apprun').addEventListener('click', function() { 10 var fileObj = document.getElementById('appselect').files[0] 11 if(fileObj.name.endsWith('.eso')) { 12 var rdr = new FileReader() 13 rdr.onload = function() { 14 devCfg.audio = new (window.AudioContext || window.webkitAudioContext) 15 vm.boot() 16 ext.setup(vm, devCfg) 17 vm.load(new Uint8Array(rdr.result)) 18 console.log('VM started') 19 vm.start(0x100) 20 } 21 rdr.readAsArrayBuffer(fileObj) 22 } 23 else window.alert('Please select an .eso file to run on ESOP') 24 }) 25 } 26 27 addEventListener('DOMContentLoaded', main)