dialogShare=saveAndShare=myCodeMirrorJava=null;var dropZoneJava=document.getElementById("dropZoneJava");document.getElementById("file-input-java").addEventListener("change",function(a){services.file.readSingleFile(a,ReadModeEnum.TEXT,function(a){myCodeMirrorJava.setValue(a)})},!1);function outputChange(){["raw","html"].forEach(function(a){document.getElementById("results-"+a).style.display=document.getElementById("output").value==a?"":"none"})} document.getElementById("output").addEventListener("change",function(a){outputChange()},!1);document.getElementById("menu-check").addEventListener("click",function(a){check()},!1);document.getElementById("browse-java").addEventListener("click",function(a){document.getElementById("file-input-java").click()},!1);document.getElementById("clipboard-java").addEventListener("click",function(a){services.copyToClipBoard(myCodeMirrorJava.getValue("\n"))},!1); document.getElementById("clipboard-result").addEventListener("click",function(a){services.copyToClipBoard(document.getElementById("results-html").innerHTML)},!1); function check(){document.getElementById("results-html").innerHTML="Compilation and execution in progress ... ";document.getElementById("results-raw").innerHTML="Compilation and execution in progress ... ";var a=myCodeMirrorJava.getValue("\n");services.http.post(myDomainAPI+"/java/"+document.getElementById("version").value,a,function(a){try{a=JSON.parse(a),document.getElementById("results-html").innerHTML=a.stdout,document.getElementById("results-raw").innerHTML=a.stdout}catch(c){document.getElementById("results-html").innerHTML= a,document.getElementById("results-raw").innerHTML=a}},function(a){a&&408==a.status?(document.getElementById("results-html").innerHTML="Timeout! Your Java code is taking too long.",document.getElementById("results-raw").innerHTML="Timeout! Your Java code is taking too long."):(document.getElementById("results-html").innerHTML="An error has occured:"+a.responseText,document.getElementById("results-raw").innerHTML="An error has occured:"+a.responseText)})} function getData(){return{version:document.getElementById("version").value,output:document.getElementById("output").value,code:pako.deflate(myCodeMirrorJava.getValue("\n"),{to:"string"})}}function closeMenu(a){a=void 0===a?null:a;document.querySelectorAll(".sub-menu ul").forEach(function(b){a&&a===b.parentNode||(b.style.display="none",b.parentNode.querySelectorAll("i.arrow").forEach(function(a){a.classList.remove("up");a.classList.add("down")}))})} addEvent(window,"load",function(){myCodeMirrorJava=services.codeMirror.create("editor-container-java",{matchBrackets:!0,mode:"text/x-java",lineWrapping:!0,continuousScanning:500,lineNumbers:!0,viewportMargin:Infinity});services.file.dragAndDrop(dropZoneJava,ReadModeEnum.TEXT,function(a){a&&myCodeMirrorJava.setValue(a)});document.getElementById("example-crypto").addEventListener("click",function(a){myCodeMirrorJava.setValue(document.getElementById("content-crypto").innerHTML)});outputChange();dialogShare= new A11yDialog(document.getElementById("dialog-share"));document.getElementById("menu-share").addEventListener("click",function(a){closeMenu();dialogShare.show()});saveAndShare=new SaveAndShare;saveAndShare.setURL("java.html");saveAndShare.setDataFct(function(){var a={};a.code=myCodeMirrorJava.getValue("\n");a.version=document.getElementById("version").value;return a});saveAndShare.setDataType("java");saveAndShare.setInitFct(function(a){a&&a.code&&myCodeMirrorJava.setValue(a.code);a&&a.version&&(document.getElementById("version").value= a.version)});saveAndShare.init();document.querySelectorAll(".sub-menu a").forEach(function(a){a.onclick=function(){for(var b=a.parentNode;b&&!b.classList.contains("sub-menu");)b=b.parentNode;b&&(closeMenu(b),b.querySelectorAll("ul").forEach(function(a){a.style.display=""==a.style.display?"none":""}),b.querySelectorAll("i.arrow").forEach(function(a){a.classList.toggle("up");a.classList.toggle("down")}))}})});