rebuilding site Mon Sep 6 01:54:11 PM CST 2021

This commit is contained in:
James Feng Cao 2021-09-06 13:54:12 +08:00
parent b706b0497a
commit 2d5aab37cc
6 changed files with 97 additions and 23 deletions

35
searchurl/ace.js Normal file
View file

@ -0,0 +1,35 @@
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;
}

24
searchurl/ace.js~ Normal file
View file

@ -0,0 +1,24 @@
var editor;
onload=function(){
function getMode(filename){
var ext = filename.split('.').pop();
var prefix = "ace/mode/";
if(!ext) return prefix + "text";
switch (ext) {
case "js":
return prefix + "javascript";
}
return prefix + ext;
}
editor = ace.edit("editor");
editor.setTheme("ace/theme/clouds");
editor.setShowPrintMargin(false);
editor.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true
});
editor.session.setMode(getMode(location.href));
}

15
searchurl/ace_t.html Normal file
View file

@ -0,0 +1,15 @@
<style type='text/css' media='screen'>
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
</style>
<script src='http://cdn.bootcss.com/ace/1.2.3/ace.js'></script>
<script src='http://cdn.bootcss.com/ace/1.2.3/ext-language_tools.js'></script>
<script src='ace.js'></script>
<pre id='editor'>
<h1>title</h1>
<div>hi</div>

15
searchurl/ace_t.html~ Normal file
View file

@ -0,0 +1,15 @@
<style type="text/css" media="screen">
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
</style>
<script src="http://cdn.bootcss.com/ace/1.2.3/ace.js"></script>
<script src="http://cdn.bootcss.com/ace/1.2.3/ext-language_tools.js"></script>
<script src="ace.js"></script>
<pre id="editor">
<h1>title</h1>
<div>hi</div>

View file

@ -1,4 +1,8 @@
var textarea;
onload=function(){
textarea=document.getElementsByTagName('textarea')[0];
}
function getNewlinePos_back(text,pos){
while(pos>=0 && text.charAt(pos)!='\n') pos--;
return pos;
@ -74,26 +78,6 @@ function moveDown(ta){
}
function onSave(){
if(!textarea)textarea=document.getElementsByTagName('textarea')[0];let u8=new TextEncoder().encode(textarea.value);let r='';for(let i=0;i<u8.byteLength;i++)r+=String.fromCharCode(u8[i]);location.href='i:0l%f:'+btoa(r);
}
function onDelete(){
if(!textarea)textarea=document.getElementsByTagName('textarea')[0];deleteLine(textarea);
}
function onUp(){
if(!textarea)textarea=document.getElementsByTagName('textarea')[0];moveUp(textarea);
}
function onDown(){
if(!textarea)textarea=document.getElementsByTagName('textarea')[0];moveDown(textarea);
}
function onTop(){
if(!textarea)textarea=document.getElementsByTagName('textarea')[0];move2Top(textarea);
}
function onBottom(){
if(!textarea)textarea=document.getElementsByTagName('textarea')[0];move2Bottom(textarea);
function onSave(fn){
let u8=new TextEncoder().encode(textarea.value);let r='';for(let i=0;i<u8.byteLength;i++)r+=String.fromCharCode(u8[i]);location.href='i:0l'+fn+':'+btoa(r);
}

View file

@ -1,7 +1,8 @@
<style>div{position:fixed;}button{height:30px}
<style>div{position:fixed;}button{width:13%;height:30px}
textarea{margin-top:30px;width:100%;height:100%;border:none;outline:none}</style>
<script src="textarea.js"></script>
<div>
<button onclick='onSave()'>Save</button>
<button onclick="onDelete()"></button>
<button onclick="onUp()"></button>
<button onclick="onDown()"></button>