mirror of
https://github.com/torappinfo/uweb.git
synced 2025-01-15 16:40:57 +01:00
36 lines
866 B
JavaScript
36 lines
866 B
JavaScript
|
var editor;
|
||
|
onload=function(){
|
||
|
var e = document.getElementById("editor");
|
||
|
var ext = location.href.split('.').pop();
|
||
|
outer:{
|
||
|
switch(ext){
|
||
|
case "html":
|
||
|
{
|
||
|
var text = e.innerHTML;
|
||
|
editor = ace.edit(e);
|
||
|
editor.session.setValue(text);
|
||
|
}
|
||
|
break outer;
|
||
|
case "js":
|
||
|
ext = "javascript";
|
||
|
}
|
||
|
editor = ace.edit(e);
|
||
|
}
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
function onRun(fn){
|
||
|
location.href='i:0m'+fn;
|
||
|
}
|