mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
46 lines
1.1 KiB
HTML
46 lines
1.1 KiB
HTML
|
<head>
|
||
|
<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 = 0;
|
||
|
var file;
|
||
|
function loadSlice(){
|
||
|
let lhash = location.hash;
|
||
|
if(lhash)
|
||
|
page = parseInt(lhash.substring(6),10);
|
||
|
file.slice(blocksize*(page-1),blocksize+extrasize).then((result)=>{
|
||
|
document.body.innerHTML = result;
|
||
|
});
|
||
|
|
||
|
}
|
||
|
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>
|