mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
enhance security
This commit is contained in:
parent
4039a5b8ec
commit
36182a2a88
4 changed files with 3 additions and 89 deletions
|
@ -1,86 +0,0 @@
|
|||
var textarea;
|
||||
onload=function(){
|
||||
textarea=document.getElementsByTagName('textarea')[0];
|
||||
}
|
||||
|
||||
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 save(fn){
|
||||
let u8=new TextEncoder().encode(textarea.value);let r=new TextDecoder('ISO-8859-1').decode(u8);location.href='i:0l'+fn+':'+r;
|
||||
}
|
||||
|
||||
function onSave(){
|
||||
save(location.pathname);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue