2021-11-06 11:30:23 +00:00
|
|
|
<head>
|
2021-11-08 07:41:41 +00:00
|
|
|
<script>window.markdeepOptions = {mode: 'script'};</script>
|
|
|
|
<script src="https://morgan3d.github.io/markdeep/latest/markdeep.min.js"></script>
|
|
|
|
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
2021-11-06 11:30:23 +00:00
|
|
|
<script>
|
|
|
|
function absFile(url) {
|
|
|
|
this.name=url;
|
|
|
|
this.slice = async(offset, length) =>{
|
|
|
|
const headers = new Headers();
|
|
|
|
headers.append('range', 'bytes=' + offset + '-' + ( offset + length -1).toString());
|
|
|
|
|
|
|
|
const opts = {
|
|
|
|
credentials: 'include',
|
|
|
|
headers : headers
|
|
|
|
};
|
|
|
|
|
|
|
|
const resp = await fetch( this.name, opts );
|
|
|
|
return await resp.arrayBuffer();
|
|
|
|
//alert(JSON.stringify(resp.headers));
|
|
|
|
//return await resp.text();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 07:41:41 +00:00
|
|
|
var file = new absFile(location.search.substring(5));//?url=#page=
|
|
|
|
window.addEventListener('hashchange',loadSlice);
|
|
|
|
loadSlice();
|
|
|
|
|
2021-11-06 11:30:23 +00:00
|
|
|
function loadSlice(){
|
2021-11-08 07:41:41 +00:00
|
|
|
var url;
|
2021-11-06 11:30:23 +00:00
|
|
|
var page = 1;
|
|
|
|
var blocksize = 1024;
|
2021-11-08 07:41:41 +00:00
|
|
|
var extrasize = 1024; //extrasize should <= blocksize
|
2021-11-06 11:30:23 +00:00
|
|
|
let lhash = location.hash;
|
|
|
|
if(lhash)
|
|
|
|
page = parseInt(lhash.substring(6),10);
|
2021-11-08 07:41:41 +00:00
|
|
|
file.slice(blocksize*(page-1),blocksize+extrasize).then((buffer)=>{
|
2021-11-06 11:30:23 +00:00
|
|
|
let u8 = new Uint8Array(buffer);
|
|
|
|
let iStart = 0;
|
|
|
|
if(1!=page){
|
2021-11-08 07:41:41 +00:00
|
|
|
for(let i=1;i<extrasize;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){
|
|
|
|
if(10==u8[i] && 10==u8[i-1]) {
|
|
|
|
iEnd = i+1;
|
|
|
|
break;
|
|
|
|
}
|
2021-11-06 11:30:23 +00:00
|
|
|
}
|
2021-11-08 07:41:41 +00:00
|
|
|
document.body.innerHTML = window.markdeep.format(new TextDecoder().decode(u8.slice(iStart,iEnd)),true);
|
|
|
|
MathJax.typesetPromise();
|
2021-11-06 11:30:23 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2021-11-08 07:41:41 +00:00
|
|
|
</body>
|