2024-09-16 13:28:28 +02:00
|
|
|
ISOTerminal.addEventListener('init', function(){
|
|
|
|
|
|
|
|
this.addEventListener('emulator-started', function(e){
|
|
|
|
|
|
|
|
const emulator = this.emulator
|
|
|
|
|
|
|
|
// unix to js device
|
|
|
|
this.readFromPipe( '/mnt/index.js', async (data) => {
|
|
|
|
const buf = await emulator.read_file("index.js")
|
|
|
|
const decoder = new TextDecoder('utf-8');
|
|
|
|
const js = decoder.decode(buf)
|
|
|
|
try{
|
2024-09-23 16:58:48 +02:00
|
|
|
this.runJavascript(js)
|
2024-09-16 13:28:28 +02:00
|
|
|
}catch(e){
|
|
|
|
console.error(e)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
2024-09-23 16:58:48 +02:00
|
|
|
ISOTerminal.prototype.runJavascript = function(js){
|
|
|
|
let $root = document.querySelector("script#root")
|
|
|
|
if( !$root ){
|
|
|
|
$root = document.createElement("script")
|
|
|
|
$root.id = "root"
|
|
|
|
document.body.appendChild($root)
|
|
|
|
}
|
|
|
|
$root.innerHTML = js
|
|
|
|
}
|
|
|
|
|