diff --git a/public/js/organization.js b/public/js/organization.js index 29fb33a..3f6085e 100644 --- a/public/js/organization.js +++ b/public/js/organization.js @@ -1,5 +1,3 @@ -var pdfRenderTasks = []; -var pdfPages = []; var windowWidth = window.innerWidth; var is_mobile = function() { return !(window.getComputedStyle(document.getElementById('is_mobile')).display === "none"); @@ -8,19 +6,23 @@ var nbPagePerLine = 5; if(is_mobile()) { nbPagePerLine = 2; } +var pdfjsLib = window['pdfjs-dist/build/pdf']; +pdfjsLib.GlobalWorkerOptions.workerSrc = '/vendor/pdf.worker.js?legacy'; +var nbPDF = 0; -var loadPDF = async function(pdfBlob, filename) { - var pdfjsLib = window['pdfjs-dist/build/pdf']; - pdfjsLib.GlobalWorkerOptions.workerSrc = '/vendor/pdf.worker.js?legacy'; +var loadPDF = async function(pdfBlob, filename, pdfIndex) { let url = await URL.createObjectURL(pdfBlob); let dataTransfer = new DataTransfer(); + for (var i = 0; i < document.getElementById('input_pdf').files.length; i++) { + dataTransfer.items.add(document.getElementById('input_pdf').files[i]); + } dataTransfer.items.add(new File([pdfBlob], filename, { type: 'application/pdf' })); document.getElementById('input_pdf').files = dataTransfer.files; - var loadingTask = pdfjsLib.getDocument(url); + let loadingTask = pdfjsLib.getDocument(url); loadingTask.promise.then(function(pdf) { for(var pageNumber = 1; pageNumber <= pdf.numPages; pageNumber++ ) { pdf.getPage(pageNumber).then(function(page) { @@ -30,9 +32,9 @@ var loadPDF = async function(pdfBlob, filename) { var pageIndex = page.pageNumber - 1; - document.getElementById('container-pages').insertAdjacentHTML('beforeend', '