mirror of https://github.com/torappinfo/uweb
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
838 B
JavaScript
35 lines
838 B
JavaScript
3 years ago
|
var editor;
|
||
|
onload=function(){
|
||
3 years ago
|
var d=document;
|
||
3 years ago
|
var ext = location.href.split('.').pop();
|
||
3 years ago
|
{
|
||
|
var ta=d.getElementById("textarea");
|
||
3 years ago
|
var text=ta.value;
|
||
3 years ago
|
var e = d.getElementById("editor");
|
||
|
|
||
3 years ago
|
switch(ext){
|
||
|
case "js":
|
||
|
ext = "javascript";
|
||
3 years ago
|
break;
|
||
|
case "py":
|
||
|
ext = "python";
|
||
|
break;
|
||
3 years ago
|
}
|
||
|
editor = ace.edit(e);
|
||
3 years ago
|
editor.session.setValue(text);
|
||
3 years ago
|
}
|
||
|
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);
|
||
|
}
|
||
|
|