simplify code
parent
3e3141be80
commit
54a997acbb
|
@ -489,7 +489,7 @@
|
||||||
<!--GuestUploadStart--><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><!--GuestUploadEnd-->
|
<!--GuestUploadStart--><script type="text/javascript" src="//cdn.bootcss.com/spark-md5/3.0.0/spark-md5.min.js"></script><!--GuestUploadEnd-->
|
||||||
<!--AliyundriveUploadJsStart--><script src="https://unpkg.com/bignumber.js@9.0.2/bignumber.js"></script>
|
<!--AliyundriveUploadJsStart--><script src="https://unpkg.com/bignumber.js@9.0.2/bignumber.js"></script>
|
||||||
<script src="https://www.unpkg.com/js-sha1@0.6.0/src/sha1.js"></script><!--AliyundriveUploadJsEnd-->
|
<script src="https://www.unpkg.com/js-sha1@0.6.0/src/sha1.js"></script><!--AliyundriveUploadJsEnd-->
|
||||||
<!--IsFileStart--><!--IspdfFileStart--><script src="https://unpkg.com/pdfjs-dist@2.13.216/build/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
|
<!--IsFileStart--><!--IspdfFileStart--><script src="https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.min.js"></script><!--IspdfFileEnd--><!--IsFileEnd-->
|
||||||
<!--ListEnd-->
|
<!--ListEnd-->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function changelanguage(str)
|
function changelanguage(str)
|
||||||
|
@ -655,61 +655,48 @@
|
||||||
addVideos(["<!--FileEncodeUrl-->"]);
|
addVideos(["<!--FileEncodeUrl-->"]);
|
||||||
<!--IsvideoFileEnd-->
|
<!--IsvideoFileEnd-->
|
||||||
<!--IspdfFileStart-->
|
<!--IspdfFileStart-->
|
||||||
//cdn.bootcss.com/pdf.js/2.3.200/pdf.worker.min.js
|
//cdn.bootcss.com/pdf.js/2.4.456/pdf.worker.min.js
|
||||||
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@2.13.216/build/pdf.worker.min.js';
|
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@2.4.456/build/pdf.worker.min.js';
|
||||||
var loadingTask = pdfjsLib.getDocument({
|
var loadingTask = pdfjsLib.getDocument({
|
||||||
url: "<!--FileDownUrl-->",
|
url: "<!--FileDownUrl-->",
|
||||||
cMapUrl: "https://unpkg.com/pdfjs-dist@2.13.216/cmaps/",
|
cMapUrl: "https://unpkg.com/pdfjs-dist@2.4.456/cmaps/",
|
||||||
cMapPacked: true,
|
cMapPacked: true,
|
||||||
disableStream: true,
|
disableStream: true,
|
||||||
disableAutoFetch: true,
|
disableAutoFetch: true,
|
||||||
rangeChunkSize: 65535*16
|
rangeChunkSize: 65535
|
||||||
});
|
});
|
||||||
loadingTask.promise.then(function(pdf) {
|
loadingTask.promise.then(function(pdf) {
|
||||||
var pagenum = pdf.numPages;
|
var pagenum = pdf.numPages;
|
||||||
var pdfContainer = document.getElementById('pdf-d');
|
var pdfContainer = document.getElementById('pdf-d');
|
||||||
pdfContainer.innerHTML = '';
|
pdfContainer.innerHTML = '';
|
||||||
if (pagenum>5) {
|
var pagepos = 1;
|
||||||
var pagepos = 0;
|
var pdfnextpagebutton = document.createElement('button');
|
||||||
for (var i=1;i<=5;i++) {
|
pdfnextpagebutton.id = 'pdfnextpagebutton';
|
||||||
var canvasNew = document.createElement('canvas');
|
pdfnextpagebutton.innerText = 'Load page ' + pagepos + '-' + (pagepos+4<pagenum?pagepos+4:pagenum) + ' (' + pagenum + ')';
|
||||||
canvasNew.id = 'pdf-c'+i;
|
pdfnextpagebutton.setAttribute('onclick', "this.style.display = 'none';");
|
||||||
pdfContainer.appendChild(canvasNew);
|
pdfnextpagebutton.style.display = 'none';
|
||||||
renderpage(pdf,i);
|
pdfContainer.appendChild(pdfnextpagebutton);
|
||||||
}
|
var pdfWaitNextPage = setInterval(function(){
|
||||||
pagepos = i;
|
//console.log(document.documentElement.scrollTop + ", " + document.body.scrollHeight);
|
||||||
var pdfnextpagebutton = document.createElement('button');
|
console.log("next page: " + pagepos + " / " + pagenum);
|
||||||
pdfnextpagebutton.id = 'pdfnextpagebutton';
|
if (pdfnextpagebutton.style.display=='none') {
|
||||||
pdfnextpagebutton.innerText = 'Load page ' + pagepos + '-' + (pagepos+4<pagenum?pagepos+4:pagenum) + ' (' + pagenum + ')';
|
for (var i=pagepos;i<=(pagepos+4<pagenum?pagepos+4:pagenum);i++) {
|
||||||
pdfnextpagebutton.setAttribute('onclick', "this.style.display = 'none';");
|
var canvasNew = document.createElement('canvas');
|
||||||
pdfContainer.appendChild(pdfnextpagebutton);
|
canvasNew.id = 'pdf-c'+i;
|
||||||
var pdfWaitNextPage = setInterval(function(){
|
pdfContainer.appendChild(canvasNew);
|
||||||
//console.log(document.documentElement.scrollTop + ", " + document.body.scrollHeight);
|
renderpage(pdf,i);
|
||||||
if (pdfnextpagebutton.style.display=='none') {
|
}
|
||||||
for (var i=pagepos;i<(pagepos+5<pagenum?pagepos+5:pagenum);i++) {
|
pagepos = i;
|
||||||
var canvasNew = document.createElement('canvas');
|
if (pagepos<pagenum) {
|
||||||
canvasNew.id = 'pdf-c'+i;
|
pdfnextpagebutton.innerText = 'Load page ' + pagepos + '-' + (pagepos+4<pagenum?pagepos+4:pagenum) + ' (' + pagenum + ')';
|
||||||
pdfContainer.appendChild(canvasNew);
|
pdfnextpagebutton.style.display ='';
|
||||||
renderpage(pdf,i);
|
pdfContainer.appendChild(pdfnextpagebutton);
|
||||||
}
|
} else {
|
||||||
pagepos = i;
|
console.log("end of pdf");
|
||||||
if (pagepos<pagenum) {
|
clearInterval(pdfWaitNextPage);
|
||||||
pdfnextpagebutton.innerText = 'Load page ' + pagepos + '-' + (pagepos+5<pagenum?pagepos+5:pagenum) + ' (' + pagenum + ')';
|
|
||||||
pdfnextpagebutton.style.display ='';
|
|
||||||
pdfContainer.appendChild(pdfnextpagebutton);
|
|
||||||
} else {
|
|
||||||
clearInterval(pdfWaitNextPage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, 1000);
|
|
||||||
} else {
|
|
||||||
for (var i=1;i<=pagenum;i++) {
|
|
||||||
var canvasNew = document.createElement('canvas');
|
|
||||||
canvasNew.id = 'pdf-c'+i;
|
|
||||||
pdfContainer.appendChild(canvasNew);
|
|
||||||
renderpage(pdf,i);
|
|
||||||
}
|
}
|
||||||
}
|
}, 1000);
|
||||||
});
|
});
|
||||||
function renderpage(pdf,i) {
|
function renderpage(pdf,i) {
|
||||||
pdf.getPage(i).then(function(page) {
|
pdf.getPage(i).then(function(page) {
|
||||||
|
|
Loading…
Reference in New Issue