rebuilding site Fri Nov 12 03:24:33 PM CST 2021

This commit is contained in:
James Feng Cao 2021-11-12 15:24:33 +08:00
parent d01266bbc1
commit 542a4e0eb4
4 changed files with 86 additions and 26 deletions

View file

@ -1,7 +1,7 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<meta name="generator" content="Hugo 0.89.0" /> <meta name="generator" content="Hugo 0.89.2" />
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />

View file

@ -131,6 +131,10 @@ socks代理</p>
重用已有窗口跳转至不同anchor。</p> 重用已有窗口跳转至不同anchor。</p>
</li> </li>
<li> <li>
<p>i:5c[url]<br>
更改自动翻页url</p>
</li>
<li>
<p>i:60[path]:[url]<br> <p>i:60[path]:[url]<br>
如果本地文件存在就打开否则访问远程url</p> 如果本地文件存在就打开否则访问远程url</p>
</li> </li>

View file

@ -21,42 +21,71 @@
} }
} }
var file = new absFile(location.search.substring(5));//?url=#page= function render(u8array){
window.addEventListener('hashchange',loadSlice); document.body.innerHTML = window.markdeep.format(new TextDecoder().decode(u8array),true);
loadSlice(); MathJax.typesetPromise();
}
var file;
var blocksize = 1024;
function loadSlice(){ function loadSlice(){
var url; var url;
var page = 1; var page = 1;
var blocksize = 1024; var extrasize = blocksize; //extrasize should <= blocksize
var extrasize = 1024; //extrasize should <= blocksize
let lhash = location.hash; let lhash = location.hash;
if(lhash) if(lhash){
page = parseInt(lhash.substring(6),10); if("p"!==lhash.charAt(1)){//#offset=&[len]
let iAmpersand = lhash.indexOf('&',8);
let offset = parseInt(lhash.substring(8,iAmpersand));
let len = parseInt(lhash.substring(iAmpersand+1));
{//update urlInc() url
let href = location.href;
let iHash = href.indexOf('#');
href="i:5c"+href.substring(0,iHash)+"#page="+Math.floor((offset+len)/blocksize);
let d=document;
let a = d.createElement('a');
a.href = href;
a.click();
}
file.slice(offset,len).then((buffer)=>{
let u8 = new Uint8Array(buffer);
render(u8);
});
return;
}
//#page=
page = parseInt(lhash.substring(6));
}
file.slice(blocksize*(page-1),blocksize+extrasize).then((buffer)=>{ file.slice(blocksize*(page-1),blocksize+extrasize).then((buffer)=>{
let u8 = new Uint8Array(buffer); let u8 = new Uint8Array(buffer);
let u8len = u8.length;
let iStart = 0; let iStart = 0;
let limit = Math.min(u8len,extrasize);
if(1!=page){ if(1!=page){
for(let i=1;i<extrasize;i=i+2){ for(let i=1;i<limit;i=i+2){
if(10==u8[i] && 10==u8[i-1]) { if(10==u8[i] && 10==u8[i-1]) {
iStart = i+1; iStart = i+1;
break; break;
} }
} }
} }
let iEnd = blocksize; let iEnd = Math.min(u8len,blocksize);
for(let i=blocksize+1;i<blocksize+extrasize;i=i+2){ limit = Math.min(u8len,blocksize+extrasize);
for(let i=blocksize+1;i<limit;i=i+2){
if(10==u8[i] && 10==u8[i-1]) { if(10==u8[i] && 10==u8[i-1]) {
iEnd = i+1; iEnd = i+1;
break; break;
} }
} }
document.body.innerHTML = window.markdeep.format(new TextDecoder().decode(u8.slice(iStart,iEnd)),true); render(u8.slice(iStart,iEnd));
MathJax.typesetPromise();
}); });
} }
//?url=#offset=&[len]&page=
file = new absFile(location.search.substring(5));
window.addEventListener('hashchange',loadSlice);
</script> </script>
</head> </head>
<body> <body>
<script>loadSlice();</script>
</body> </body>

View file

@ -19,43 +19,70 @@
} }
} }
function render(u8array){
document.body.innerHTML = marked(new TextDecoder().decode(u8array));
}
var file; var file;
var blocksize = 1024;
function loadSlice(){ function loadSlice(){
var url; var url;
var page = 1; var page = 1;
var blocksize = 1024; var extrasize = blocksize; //extrasize should <= blocksize
var extrasize = 1024; //extrasize should <= blocksize
let lhash = location.hash; let lhash = location.hash;
if(lhash) if(lhash){
page = parseInt(lhash.substring(6),10); if("p"!==lhash.charAt(1)){//#offset=&[len]
let iAmpersand = lhash.indexOf('&',8);
let offset = parseInt(lhash.substring(8,iAmpersand));
let len = parseInt(lhash.substring(iAmpersand+1));
{//update urlInc() url
let href = location.href;
let iHash = href.indexOf('#');
href="i:5c"+href.substring(0,iHash)+"#page="+Math.floor((offset+len)/blocksize);
let d=document;
let a = d.createElement('a');
a.href = href;
a.click();
}
file.slice(offset,len).then((buffer)=>{
let u8 = new Uint8Array(buffer);
render(u8);
});
return;
}
//#page=
page = parseInt(lhash.substring(6));
}
file.slice(blocksize*(page-1),blocksize+extrasize).then((buffer)=>{ file.slice(blocksize*(page-1),blocksize+extrasize).then((buffer)=>{
let u8 = new Uint8Array(buffer); let u8 = new Uint8Array(buffer);
let u8len = u8.length;
let iStart = 0; let iStart = 0;
let limit = Math.min(u8len,extrasize);
if(1!=page){ if(1!=page){
for(let i=1;i<extrasize;i=i+2){ for(let i=1;i<limit;i=i+2){
if(10==u8[i] && 10==u8[i-1]) { if(10==u8[i] && 10==u8[i-1]) {
iStart = i+1; iStart = i+1;
break; break;
} }
} }
} }
let iEnd = blocksize; let iEnd = Math.min(u8len,blocksize);
for(let i=blocksize+1;i<blocksize+extrasize;i=i+2){ limit = Math.min(u8len,blocksize+extrasize);
for(let i=blocksize+1;i<limit;i=i+2){
if(10==u8[i] && 10==u8[i-1]) { if(10==u8[i] && 10==u8[i-1]) {
iEnd = i+1; iEnd = i+1;
break; break;
} }
} }
document.body.innerHTML = marked(new TextDecoder().decode(u8.slice(iStart,iEnd))); render(u8.slice(iStart,iEnd));
}); });
} }
window.addEventListener('hashchange',loadSlice); //?url=#offset=&[len]&page=
//?url=#page=
file = new absFile(location.search.substring(5)); file = new absFile(location.search.substring(5));
//let viewElement = document.querySelector("#viewer"); window.addEventListener('hashchange',loadSlice);
loadSlice();
</script> </script>
</head> </head>
<body> <body>
<script>loadSlice();</script>
</body> </body>