update AI engines
[uweb.git] / zh / searchurl / ace.js
bloba10728ecfa89d942ddcc5101efcf4058bcf72257
1 var editor;
2 onload=function(){
3 var d=document;
4 var ext = location.href.split('.').pop();
6 var ta=d.getElementById("textarea");
7 var text=ta.value;
8 var e = d.getElementById("editor");
10 switch(ext){
11 case "js":
12 ext = "javascript";
13 break;
14 case "py":
15 ext = "python";
16 break;
18 editor = ace.edit(e);
19 editor.session.setValue(text);
21 editor.session.setMode("ace/mode/"+ext);
22 editor.setTheme("ace/theme/clouds");
23 editor.setShowPrintMargin(false);
24 editor.setOptions({
25 enableBasicAutocompletion: true,
26 enableSnippets: true,
27 enableLiveAutocompletion: true
28 });
31 function onSave(fn){
32 let u8=new TextEncoder().encode(editor.session.getValue());let r='';for(let i=0;i<u8.byteLength;i++)r+=String.fromCharCode(u8[i]);location.href='i:0l'+fn+':'+btoa(r);