mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
rebuilding site Sat Nov 6 07:30:22 PM CST 2021
This commit is contained in:
parent
20334d14bf
commit
6bac3bc9bb
3 changed files with 121 additions and 6 deletions
52
searchurl/txt/markdeep.html
Normal file
52
searchurl/txt/markdeep.html
Normal file
|
@ -0,0 +1,52 @@
|
|||
<head>
|
||||
<link rel="stylesheet" href="https://morgan3d.github.io/markdeep/latest/latex.css?"><!-- Markdeep: --><style class="fallback">body{visibility:hidden}</style>
|
||||
<script src="https://morgan3d.github.io/markdeep/latest/markdeep.min.js?" charset="utf-8"></script>
|
||||
<script>
|
||||
window.addEventListener('hashchange',loadSlice);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
var uwebfile;
|
||||
function loadSlice(){
|
||||
var page = 1;
|
||||
var blocksize = 1024;
|
||||
var extrasize = 2048;
|
||||
|
||||
let lhash = location.hash;
|
||||
if(lhash)
|
||||
page = parseInt(lhash.substring(6),10);
|
||||
uwebfile.slice(blocksize*(page-1),blocksize+extrasize).then((buffer)=>{
|
||||
let u8 = new Uint8Array(buffer);
|
||||
let iStart = 0;
|
||||
if(1!=page){
|
||||
while(10!=u8[iStart]) iStart++;
|
||||
}
|
||||
let iEnd = u8.indexOf(10,blocksize);//fine newline(10)
|
||||
if(-1==iEnd) iEnd = blocksize;
|
||||
iEnd++;
|
||||
document.body.innerHTML = new TextDecoder().decode(u8.slice(iStart,iEnd));
|
||||
});
|
||||
|
||||
}
|
||||
//?url=#page=
|
||||
uwebfile = new absFile(location.search.substring(5));
|
||||
loadSlice();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<body>
|
54
searchurl/txt/markdeep.html~
Normal file
54
searchurl/txt/markdeep.html~
Normal file
|
@ -0,0 +1,54 @@
|
|||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
<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();
|
||||
}
|
||||
}
|
||||
|
||||
var url;
|
||||
var page = 1;
|
||||
var blocksize = 1024;
|
||||
var extrasize = 2048;
|
||||
var file;
|
||||
function loadSlice(){
|
||||
let lhash = location.hash;
|
||||
if(lhash)
|
||||
page = parseInt(lhash.substring(6),10);
|
||||
file.slice(blocksize*(page-1),blocksize+extrasize).then((buffer)=>{
|
||||
let u8 = new Uint8Array(buffer);
|
||||
let iStart = 0;
|
||||
if(1!=page){
|
||||
while(10!=u8[iStart]) iStart++;
|
||||
}
|
||||
let iEnd = u8.indexOf(10,blocksize);//fine newline(10)
|
||||
if(-1==iEnd) iEnd = blocksize;
|
||||
iEnd++;
|
||||
document.body.innerHTML = marked(new TextDecoder().decode(u8.slice(iStart,iEnd)));
|
||||
});
|
||||
|
||||
}
|
||||
window.addEventListener('hashchange',loadSlice);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
//?url=#page=
|
||||
file = new absFile(location.search.substring(5));
|
||||
//let viewElement = document.querySelector("#viewer");
|
||||
loadSlice();
|
||||
</script>
|
||||
<body>
|
|
@ -1,5 +1,5 @@
|
|||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked@3.0.7/marked.min.js"></script>
|
||||
<script>
|
||||
function absFile(url) {
|
||||
this.name=url;
|
||||
|
@ -22,7 +22,7 @@
|
|||
var url;
|
||||
var page = 1;
|
||||
var blocksize = 1024;
|
||||
var extrasize = 2048;
|
||||
var extrasize = 1024; //extrasize should <= blocksize
|
||||
var file;
|
||||
function loadSlice(){
|
||||
let lhash = location.hash;
|
||||
|
@ -32,11 +32,20 @@
|
|||
let u8 = new Uint8Array(buffer);
|
||||
let iStart = 0;
|
||||
if(1!=page){
|
||||
while(10!=u8[iStart]) iStart++;
|
||||
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;
|
||||
}
|
||||
}
|
||||
let iEnd = u8.indexOf(10,blocksize);//fine newline(10)
|
||||
if(-1==iEnd) iEnd = blocksize;
|
||||
iEnd++;
|
||||
document.body.innerHTML = marked(new TextDecoder().decode(u8.slice(iStart,iEnd)));
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue