2021-09-06 05:54:12 +00:00
|
|
|
var editor;
|
|
|
|
onload=function(){
|
2021-09-07 08:46:47 +00:00
|
|
|
var d=document;
|
2021-09-06 05:54:12 +00:00
|
|
|
var ext = location.href.split('.').pop();
|
2021-09-07 08:46:47 +00:00
|
|
|
{
|
|
|
|
var ta=d.getElementById("textarea");
|
2021-09-08 08:26:37 +00:00
|
|
|
var text=ta.value;
|
2021-09-07 08:46:47 +00:00
|
|
|
var e = d.getElementById("editor");
|
|
|
|
|
2021-09-06 05:54:12 +00:00
|
|
|
switch(ext){
|
|
|
|
case "js":
|
|
|
|
ext = "javascript";
|
2021-09-26 13:00:26 +00:00
|
|
|
break;
|
|
|
|
case "py":
|
|
|
|
ext = "python";
|
|
|
|
break;
|
2021-09-06 05:54:12 +00:00
|
|
|
}
|
|
|
|
editor = ace.edit(e);
|
2021-09-07 08:46:47 +00:00
|
|
|
editor.session.setValue(text);
|
2021-09-06 05:54:12 +00:00
|
|
|
}
|
|
|
|
editor.session.setMode("ace/mode/"+ext);
|
|
|
|
editor.setTheme("ace/theme/clouds");
|
|
|
|
editor.setShowPrintMargin(false);
|
|
|
|
editor.setOptions({
|
|
|
|
enableBasicAutocompletion: true,
|
|
|
|
enableSnippets: true,
|
|
|
|
enableLiveAutocompletion: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSave(fn){
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|