rebuilding site Sun Aug 29 07:49:58 AM CST 2021

This commit is contained in:
James Feng Cao 2021-08-29 07:49:58 +08:00
parent c00a8e0463
commit b706b0497a
5 changed files with 153 additions and 21 deletions

View file

@ -1,20 +1,19 @@
<script src="config.js"></script>
<style>
textarea{width:100%;height:100%;border:none;outline:none}</style>
<script src="textarea.js"></script>
<button onclick="onDelete()">X</button>
<button onclick="onMoveUp()">Up</button>
<button onclick="onMoveDown()">Down</button>
<button onclick="onTop()">Top</button>
<button onclick="onBottom()">Bottom</button>
<textarea autofocus />
H1
h2
h3
h4
h5
h6
h7
h8
h9
ha

View file

@ -2,6 +2,6 @@ apt update
apt upgrade
apt install axel
(cat /sdcard/uweb/default.longclick;cat<<HERE )|awk '!s[$0]++'>a.tmp;mv a.tmp /sdcard/uweb/default.longclick
axel:cd /sdcard/Download;axel -n 9
axel::cd /sdcard/Download;axel -n 9
HERE

99
searchurl/textarea.js Normal file
View file

@ -0,0 +1,99 @@
var textarea;
function getNewlinePos_back(text,pos){
while(pos>=0 && text.charAt(pos)!='\n') pos--;
return pos;
}
function getNewlinePos_forth(text,pos){
let len = text.length;
while(pos<len && text.charAt(pos)!='\n') pos++;
return pos;
}
function deleteLine(ta){
let text = ta.value;
let lStart = getNewlinePos_back(text,ta.selectionStart-1);
let lEnd = getNewlinePos_forth(text,ta.selectionEnd);
ta.value = text.substring(0,lStart+1) + text.substring(lEnd+1);
ta.selectionStart = ta.selectionEnd = lStart +1;
ta.focus();
}
function moveUp(ta){
let text = ta.value;
let start = ta.selectionStart;
let end = ta.selectionEnd;
let lStart = getNewlinePos_back(text,start-1);
let lEnd = getNewlinePos_forth(text,end);
let prevS = getNewlinePos_back(text,lStart-1);
ta.value = text.substring(0,prevS+1)+text.substring(lStart+1,lEnd+1)+
text.substring(prevS+1,lStart+1) + text.substring(lEnd+1);
ta.selectionStart = start - (lStart - prevS);
ta.selectionEnd = end - (lStart - prevS);
ta.focus();
}
function move2Top(ta){
let text = ta.value;
let start = ta.selectionStart;
let end = ta.selectionEnd;
let lStart = getNewlinePos_back(text,start-1);
let lEnd = getNewlinePos_forth(text,end);
ta.value = text.substring(lStart+1,lEnd+1)+text.substring(0,lStart+1)+
text.substring(lEnd+1);
ta.selectionStart = start - lStart-1;
ta.selectionEnd = end - lStart-1;
ta.focus();
}
function move2Bottom(ta){
let text = ta.value;
let start = ta.selectionStart;
let end = ta.selectionEnd;
let lStart = getNewlinePos_back(text,start-1);
let lEnd = getNewlinePos_forth(text,end);
ta.value = text.substring(0,lStart+1)+text.substring(lEnd+1)+
text.substring(lStart+1,lEnd+1);
ta.selectionStart = start + text.length - lEnd-1;
ta.selectionEnd = end + text.length - lEnd-1;
ta.focus();
}
function moveDown(ta){
let text = ta.value;
let start = ta.selectionStart;
let end = ta.selectionEnd;
let lStart = getNewlinePos_back(text,start-1);
let lEnd = getNewlinePos_forth(text,end);
let nextE = getNewlinePos_forth(text,lEnd+1);
ta.value = text.substring(0,lStart+1) + text.substring(lEnd+1,nextE+1) +
text.substring(lStart+1,lEnd+1)+text.substring(nextE+1);
ta.selectionStart = start + (nextE - lEnd);
ta.selectionEnd = end + (nextE - lEnd);
ta.focus();
}
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);
}

13
searchurl/textarea.js~ Normal file
View file

@ -0,0 +1,13 @@
var textarea;
function deleteLine(ta){
let startPos = ta.selectionStart;
let endPos = ta.selectionEnd;
let text = ta.value;
let lStart = startPos-1;
while(lStart>=0 && text.charAt(lStart)!='\n') lStart--;
let lEnd = endPos;
let len = text.length;
while(lEnd<len && text.charAt(lEnd)!='\n') lEnd++;
ta.value = text.substring(0,lStart+1) + text.substring(lEnd+1);
ta.selectionStart = ta.selectionEnd = lStart +1;
}

21
searchurl/textarea_t.html Normal file
View file

@ -0,0 +1,21 @@
<style>div{position:fixed;}button{height:30px}
textarea{margin-top:30px;width:100%;height:100%;border:none;outline:none}</style>
<script src="textarea.js"></script>
<div>
<button onclick="onDelete()"></button>
<button onclick="onUp()"></button>
<button onclick="onDown()"></button>
<button onclick="onTop()"></button>
<button onclick="onBottom()"></button>
</div>
<textarea autofocus />
H1
h2
h3
h4
h5
h6
h7
h8
h9
ha