mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
rebuilding site Fri Nov 12 03:24:33 PM CST 2021
This commit is contained in:
parent
d01266bbc1
commit
542a4e0eb4
4 changed files with 86 additions and 26 deletions
|
@ -1,7 +1,7 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="generator" content="Hugo 0.89.0" />
|
||||
<meta name="generator" content="Hugo 0.89.2" />
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
|
|
|
@ -131,6 +131,10 @@ socks代理</p>
|
|||
重用已有窗口跳转至不同anchor。</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>i:5c[url]<br>
|
||||
更改自动翻页url</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>i:60[path]:[url]<br>
|
||||
如果本地文件存在就打开,否则访问远程url</p>
|
||||
</li>
|
||||
|
|
|
@ -21,42 +21,71 @@
|
|||
}
|
||||
}
|
||||
|
||||
var file = new absFile(location.search.substring(5));//?url=#page=
|
||||
window.addEventListener('hashchange',loadSlice);
|
||||
loadSlice();
|
||||
function render(u8array){
|
||||
document.body.innerHTML = window.markdeep.format(new TextDecoder().decode(u8array),true);
|
||||
MathJax.typesetPromise();
|
||||
}
|
||||
|
||||
var file;
|
||||
var blocksize = 1024;
|
||||
function loadSlice(){
|
||||
var url;
|
||||
var page = 1;
|
||||
var blocksize = 1024;
|
||||
var extrasize = 1024; //extrasize should <= blocksize
|
||||
var extrasize = blocksize; //extrasize should <= blocksize
|
||||
let lhash = location.hash;
|
||||
if(lhash)
|
||||
page = parseInt(lhash.substring(6),10);
|
||||
if(lhash){
|
||||
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)=>{
|
||||
let u8 = new Uint8Array(buffer);
|
||||
let u8len = u8.length;
|
||||
let iStart = 0;
|
||||
let limit = Math.min(u8len,extrasize);
|
||||
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]) {
|
||||
iStart = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
let iEnd = blocksize;
|
||||
for(let i=blocksize+1;i<blocksize+extrasize;i=i+2){
|
||||
let iEnd = Math.min(u8len,blocksize);
|
||||
limit = Math.min(u8len,blocksize+extrasize);
|
||||
for(let i=blocksize+1;i<limit;i=i+2){
|
||||
if(10==u8[i] && 10==u8[i-1]) {
|
||||
iEnd = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
document.body.innerHTML = window.markdeep.format(new TextDecoder().decode(u8.slice(iStart,iEnd)),true);
|
||||
MathJax.typesetPromise();
|
||||
render(u8.slice(iStart,iEnd));
|
||||
});
|
||||
|
||||
}
|
||||
//?url=#offset=&[len]&page=
|
||||
file = new absFile(location.search.substring(5));
|
||||
window.addEventListener('hashchange',loadSlice);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<script>loadSlice();</script>
|
||||
</body>
|
||||
|
|
|
@ -19,43 +19,70 @@
|
|||
}
|
||||
}
|
||||
|
||||
function render(u8array){
|
||||
document.body.innerHTML = marked(new TextDecoder().decode(u8array));
|
||||
}
|
||||
|
||||
var file;
|
||||
var blocksize = 1024;
|
||||
function loadSlice(){
|
||||
var url;
|
||||
var page = 1;
|
||||
var blocksize = 1024;
|
||||
var extrasize = 1024; //extrasize should <= blocksize
|
||||
var extrasize = blocksize; //extrasize should <= blocksize
|
||||
let lhash = location.hash;
|
||||
if(lhash)
|
||||
page = parseInt(lhash.substring(6),10);
|
||||
if(lhash){
|
||||
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)=>{
|
||||
let u8 = new Uint8Array(buffer);
|
||||
let u8len = u8.length;
|
||||
let iStart = 0;
|
||||
let limit = Math.min(u8len,extrasize);
|
||||
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]) {
|
||||
iStart = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
let iEnd = blocksize;
|
||||
for(let i=blocksize+1;i<blocksize+extrasize;i=i+2){
|
||||
let iEnd = Math.min(u8len,blocksize);
|
||||
limit = Math.min(u8len,blocksize+extrasize);
|
||||
for(let i=blocksize+1;i<limit;i=i+2){
|
||||
if(10==u8[i] && 10==u8[i-1]) {
|
||||
iEnd = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
document.body.innerHTML = marked(new TextDecoder().decode(u8.slice(iStart,iEnd)));
|
||||
render(u8.slice(iStart,iEnd));
|
||||
});
|
||||
|
||||
}
|
||||
window.addEventListener('hashchange',loadSlice);
|
||||
//?url=#page=
|
||||
//?url=#offset=&[len]&page=
|
||||
file = new absFile(location.search.substring(5));
|
||||
//let viewElement = document.querySelector("#viewer");
|
||||
loadSlice();
|
||||
window.addEventListener('hashchange',loadSlice);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<script>loadSlice();</script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue