mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-23 16:05:09 +00:00
🤖 format everything with pre-commit by <stirlingbot> (#3220)
Auto-generated by [create-pull-request][1] with **stirlingbot** [1]: https://github.com/peter-evans/create-pull-request Signed-off-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com> Co-authored-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com>
This commit is contained in:
parent
de905f4774
commit
0012831da9
@ -864,4 +864,4 @@ public class CompressController {
|
|||||||
}
|
}
|
||||||
return Math.min(9, currentLevel + 1);
|
return Math.min(9, currentLevel + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ export class DecryptFile {
|
|||||||
constructor(){
|
constructor(){
|
||||||
this.decryptWorker = null
|
this.decryptWorker = null
|
||||||
}
|
}
|
||||||
|
|
||||||
async decryptFile(file, requiresPassword) {
|
async decryptFile(file, requiresPassword) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -87,7 +87,7 @@ export class DecryptFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pdfjsLib.GlobalWorkerOptions.workerSrc = './pdfjs-legacy/pdf.worker.mjs';
|
pdfjsLib.GlobalWorkerOptions.workerSrc = './pdfjs-legacy/pdf.worker.mjs';
|
||||||
|
|
||||||
const arrayBuffer = await file.arrayBuffer();
|
const arrayBuffer = await file.arrayBuffer();
|
||||||
const arrayBufferForPdfLib = arrayBuffer.slice(0);
|
const arrayBufferForPdfLib = arrayBuffer.slice(0);
|
||||||
var loadingTask;
|
var loadingTask;
|
||||||
@ -98,7 +98,7 @@ export class DecryptFile {
|
|||||||
});
|
});
|
||||||
this.decryptWorker = loadingTask._worker
|
this.decryptWorker = loadingTask._worker
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
loadingTask = pdfjsLib.getDocument({
|
loadingTask = pdfjsLib.getDocument({
|
||||||
data: arrayBuffer,
|
data: arrayBuffer,
|
||||||
worker: this.decryptWorker
|
worker: this.decryptWorker
|
||||||
|
@ -144,10 +144,10 @@ function setupFileInput(chooser) {
|
|||||||
const originalText = inputContainer.querySelector('#fileInputText').innerHTML;
|
const originalText = inputContainer.querySelector('#fileInputText').innerHTML;
|
||||||
|
|
||||||
inputContainer.querySelector('#fileInputText').innerHTML = window.fileInput.loading;
|
inputContainer.querySelector('#fileInputText').innerHTML = window.fileInput.loading;
|
||||||
|
|
||||||
async function checkZipFile() {
|
async function checkZipFile() {
|
||||||
const hasZipFiles = allFiles.some(file => zipTypes.includes(file.type));
|
const hasZipFiles = allFiles.some(file => zipTypes.includes(file.type));
|
||||||
|
|
||||||
// Only change to extractPDF message if we actually have zip files
|
// Only change to extractPDF message if we actually have zip files
|
||||||
if (hasZipFiles) {
|
if (hasZipFiles) {
|
||||||
inputContainer.querySelector('#fileInputText').innerHTML = window.fileInput.extractPDF;
|
inputContainer.querySelector('#fileInputText').innerHTML = window.fileInput.extractPDF;
|
||||||
@ -167,7 +167,7 @@ function setupFileInput(chooser) {
|
|||||||
|
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
const decryptFile = new DecryptFile();
|
const decryptFile = new DecryptFile();
|
||||||
|
|
||||||
await checkZipFile();
|
await checkZipFile();
|
||||||
@ -184,7 +184,7 @@ function setupFileInput(chooser) {
|
|||||||
}
|
}
|
||||||
decryptedFile.uniqueId = UUID.uuidv4();
|
decryptedFile.uniqueId = UUID.uuidv4();
|
||||||
return decryptedFile;
|
return decryptedFile;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error decrypting file: ${file.name}`, error);
|
console.error(`Error decrypting file: ${file.name}`, error);
|
||||||
if (!file.uniqueId) file.uniqueId = UUID.uuidv4();
|
if (!file.uniqueId) file.uniqueId = UUID.uuidv4();
|
||||||
@ -214,9 +214,9 @@ function setupFileInput(chooser) {
|
|||||||
var counter = 0;
|
var counter = 0;
|
||||||
|
|
||||||
// do an overall count, then proceed to make the pdf files
|
// do an overall count, then proceed to make the pdf files
|
||||||
await jszip.loadAsync(zipFile)
|
await jszip.loadAsync(zipFile)
|
||||||
.then(function (zip) {
|
.then(function (zip) {
|
||||||
|
|
||||||
zip.forEach(function (relativePath, zipEntry) {
|
zip.forEach(function (relativePath, zipEntry) {
|
||||||
counter+=1;
|
counter+=1;
|
||||||
})
|
})
|
||||||
@ -237,11 +237,11 @@ function setupFileInput(chooser) {
|
|||||||
if (content.size > 0) {
|
if (content.size > 0) {
|
||||||
const extension = zipEntry.name.split('.').pop().toLowerCase();
|
const extension = zipEntry.name.split('.').pop().toLowerCase();
|
||||||
const mimeType = mimeTypes[extension] || 'application/octet-stream';
|
const mimeType = mimeTypes[extension] || 'application/octet-stream';
|
||||||
|
|
||||||
// Check if we're accepting ONLY ZIP files (in which case extract everything)
|
// Check if we're accepting ONLY ZIP files (in which case extract everything)
|
||||||
// or if the file type matches the accepted type
|
// or if the file type matches the accepted type
|
||||||
if (zipTypes.includes(acceptedFileType) ||
|
if (zipTypes.includes(acceptedFileType) ||
|
||||||
acceptedFileType === '*/*' ||
|
acceptedFileType === '*/*' ||
|
||||||
(mimeType && (mimeType.startsWith(acceptedFileType.split('/')[0]) || acceptedFileType === mimeType))) {
|
(mimeType && (mimeType.startsWith(acceptedFileType.split('/')[0]) || acceptedFileType === mimeType))) {
|
||||||
var file = new File([content], zipEntry.name, { type: mimeType });
|
var file = new File([content], zipEntry.name, { type: mimeType });
|
||||||
file.uniqueId = UUID.uuidv4();
|
file.uniqueId = UUID.uuidv4();
|
||||||
@ -251,10 +251,10 @@ function setupFileInput(chooser) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
extractionPromises.push(promise);
|
extractionPromises.push(promise);
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.all(extractionPromises);
|
return Promise.all(extractionPromises);
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
@ -262,7 +262,7 @@ function setupFileInput(chooser) {
|
|||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFileInputChange(inputElement) {
|
function handleFileInputChange(inputElement) {
|
||||||
|
|
||||||
const files = allFiles;
|
const files = allFiles;
|
||||||
|
@ -34,7 +34,7 @@ document.querySelector("#navbarSearchInput").addEventListener("input", function
|
|||||||
|
|
||||||
if (searchText !== "") {
|
if (searchText !== "") {
|
||||||
var addedResults = new Set();
|
var addedResults = new Set();
|
||||||
|
|
||||||
items.forEach(function (item) {
|
items.forEach(function (item) {
|
||||||
var titleElement = item.querySelector(".icon-text");
|
var titleElement = item.querySelector(".icon-text");
|
||||||
var iconElement = item.querySelector(".material-symbols-rounded, .icon");
|
var iconElement = item.querySelector(".material-symbols-rounded, .icon");
|
||||||
@ -50,15 +50,15 @@ document.querySelector("#navbarSearchInput").addEventListener("input", function
|
|||||||
) {
|
) {
|
||||||
var dropdownItem = document.createElement("div");
|
var dropdownItem = document.createElement("div");
|
||||||
dropdownItem.className = "dropdown-item d-flex justify-content-between align-items-center";
|
dropdownItem.className = "dropdown-item d-flex justify-content-between align-items-center";
|
||||||
|
|
||||||
var contentWrapper = document.createElement("div");
|
var contentWrapper = document.createElement("div");
|
||||||
contentWrapper.className = "d-flex align-items-center flex-grow-1";
|
contentWrapper.className = "d-flex align-items-center flex-grow-1";
|
||||||
contentWrapper.style.textDecoration = "none";
|
contentWrapper.style.textDecoration = "none";
|
||||||
contentWrapper.style.color = "inherit";
|
contentWrapper.style.color = "inherit";
|
||||||
|
|
||||||
var originalContent = item.querySelector("div").cloneNode(true);
|
var originalContent = item.querySelector("div").cloneNode(true);
|
||||||
contentWrapper.appendChild(originalContent);
|
contentWrapper.appendChild(originalContent);
|
||||||
|
|
||||||
contentWrapper.onclick = function () {
|
contentWrapper.onclick = function () {
|
||||||
window.location.href = itemHref;
|
window.location.href = itemHref;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user