-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain-old.js
30 lines (30 loc) · 1.37 KB
/
main-old.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
window.addEventListener("load",function(){
if(!window.WebAssembly){
alert("This browser does not support WebAssembly. Chrome 57+, Firefox 52+ and Opera 44+ are great browsers that do support WebAssembly, and they're free!");
return;
}
var codeTextbox=document.getElementById("codetextbox");
var inputTextbox=document.getElementById("inputtextbox");
var outputTextbox=document.getElementById("outputtextbox");
var codeButton=document.getElementById("codebutton");
var clearOutputButton=document.getElementById("clearoutputbutton");
codeButton.addEventListener("click",function(){
var codestr=codeTextbox.value;
var instr=inputTextbox.value;
outputTextbox.value="";
var startTime=Date.now();
JellyBF.compileOptimized(codestr,{infiniteloops:false},function(compiledModule){
var compiledTime=Date.now();
console.log("Compiled in "+Math.round(compiledTime-startTime)+" ms.");
compiledTime=Date.now();
JellyBF.execute(compiledModule,instr,function(outstr){
var executedTime=Date.now();
console.log("Executed in "+Math.round(executedTime-compiledTime)+" ms.");
outputTextbox.value=outstr;
});
});
});
clearOutputButton.addEventListener("click",function(){
outputTextbox.value="";
});
});