enhance security

This commit is contained in:
James Feng Cao 2023-11-21 16:23:28 +08:00
parent 4039a5b8ec
commit 36182a2a88
4 changed files with 3 additions and 89 deletions

View file

@ -84,7 +84,7 @@
</div> </div>
<p>Last Modified: 21 November 2023<br> <p>Last Modified: 21 November 2023<br>
scripting mode for i:0 urls<br> enhance security<br>
<pre></pre> <pre></pre>
</p> </p>
<script> <script>

View file

@ -98,7 +98,7 @@
</div> </div>
<p>Last Modified: 21 November 2023<br> <p>Last Modified: 21 November 2023<br>
textarea2.js 8x performance improvement for file saving<br> enhance security<br>
<pre></pre> <pre></pre>
</p> </p>
<script> <script>

View file

@ -1,6 +1,6 @@
<script> <script>
let verCode = %1%; let verCode = %1%;
let latestV = 1027; let latestV = 1028;
if( verCode>=latestV) alert("No updates available!"); if( verCode>=latestV) alert("No updates available!");
else else
location.href = "https://s1.asytech.cn/s/tQrgT5kBRg8Trry/download?path=%2F&files=uweb"+ location.href = "https://s1.asytech.cn/s/tQrgT5kBRg8Trry/download?path=%2F&files=uweb"+

View file

@ -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);
}