Update version to 1.6.2 and enhance navigation links across HTML pages
- Updated version number in package-lock.json and relevant HTML files. - Changed navigation links to point to the root path for consistency. - Improved code formatting and structure in various JavaScript and HTML files for better readability.
This commit is contained in:
@@ -16,13 +16,12 @@ function showStatus(
|
||||
type: 'success' | 'error' | 'info' = 'info'
|
||||
) {
|
||||
statusMessage.textContent = message
|
||||
statusMessage.className = `mt-4 p-3 rounded-lg text-sm ${
|
||||
type === 'success'
|
||||
statusMessage.className = `mt-4 p-3 rounded-lg text-sm ${type === 'success'
|
||||
? 'bg-green-900 text-green-200'
|
||||
: type === 'error'
|
||||
? 'bg-red-900 text-red-200'
|
||||
: 'bg-blue-900 text-blue-200'
|
||||
}`
|
||||
}`
|
||||
statusMessage.classList.remove('hidden')
|
||||
}
|
||||
|
||||
@@ -36,7 +35,7 @@ function updateFileList() {
|
||||
fileListDiv.classList.add('hidden')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
fileListDiv.classList.remove('hidden')
|
||||
selectedFiles.forEach((file) => {
|
||||
const fileDiv = document.createElement('div')
|
||||
@@ -61,7 +60,7 @@ pdfFilesInput.addEventListener('change', (e) => {
|
||||
selectedFiles = Array.from(target.files)
|
||||
convertBtn.disabled = selectedFiles.length === 0
|
||||
updateFileList()
|
||||
|
||||
|
||||
if (selectedFiles.length === 0) {
|
||||
showStatus('Please select at least 1 PDF file', 'info')
|
||||
} else {
|
||||
@@ -87,10 +86,10 @@ async function convertPDFsToJSON() {
|
||||
showStatus('Converting PDFs to JSON..', 'info')
|
||||
|
||||
worker.postMessage({
|
||||
command: 'convert',
|
||||
fileBuffers: fileBuffers,
|
||||
fileNames: selectedFiles.map(f => f.name)
|
||||
}, fileBuffers);
|
||||
command: 'convert',
|
||||
fileBuffers: fileBuffers,
|
||||
fileNames: selectedFiles.map(f => f.name)
|
||||
}, fileBuffers);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error reading files:', error)
|
||||
@@ -100,51 +99,51 @@ async function convertPDFsToJSON() {
|
||||
}
|
||||
|
||||
worker.onmessage = async (e: MessageEvent) => {
|
||||
convertBtn.disabled = false;
|
||||
|
||||
if (e.data.status === 'success') {
|
||||
const jsonFiles = e.data.jsonFiles as Array<{ name: string, data: ArrayBuffer }>;
|
||||
|
||||
try {
|
||||
showStatus('Creating ZIP file...', 'info')
|
||||
|
||||
const zip = new JSZip()
|
||||
jsonFiles.forEach(({ name, data }) => {
|
||||
const jsonName = name.replace(/\.pdf$/i, '.json')
|
||||
const uint8Array = new Uint8Array(data)
|
||||
zip.file(jsonName, uint8Array)
|
||||
})
|
||||
|
||||
const zipBlob = await zip.generateAsync({ type: 'blob' })
|
||||
downloadFile(zipBlob, 'pdfs-to-json.zip')
|
||||
convertBtn.disabled = false;
|
||||
|
||||
showStatus('✅ PDFs converted to JSON successfully! ZIP download started.', 'success')
|
||||
|
||||
selectedFiles = []
|
||||
pdfFilesInput.value = ''
|
||||
fileListDiv.innerHTML = ''
|
||||
fileListDiv.classList.add('hidden')
|
||||
convertBtn.disabled = true
|
||||
|
||||
setTimeout(() => {
|
||||
hideStatus()
|
||||
}, 3000)
|
||||
if (e.data.status === 'success') {
|
||||
const jsonFiles = e.data.jsonFiles as Array<{ name: string, data: ArrayBuffer }>;
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error creating ZIP:', error)
|
||||
showStatus(`❌ Error creating ZIP: ${error instanceof Error ? error.message : 'Unknown error'}`, 'error')
|
||||
}
|
||||
try {
|
||||
showStatus('Creating ZIP file...', 'info')
|
||||
|
||||
} else if (e.data.status === 'error') {
|
||||
const errorMessage = e.data.message || 'Unknown error occurred in worker.';
|
||||
console.error('Worker Error:', errorMessage);
|
||||
showStatus(`❌ Worker Error: ${errorMessage}`, 'error');
|
||||
const zip = new JSZip()
|
||||
jsonFiles.forEach(({ name, data }) => {
|
||||
const jsonName = name.replace(/\.pdf$/i, '.json')
|
||||
const uint8Array = new Uint8Array(data)
|
||||
zip.file(jsonName, uint8Array)
|
||||
})
|
||||
|
||||
const zipBlob = await zip.generateAsync({ type: 'blob' })
|
||||
downloadFile(zipBlob, 'pdfs-to-json.zip')
|
||||
|
||||
showStatus('✅ PDFs converted to JSON successfully! ZIP download started.', 'success')
|
||||
|
||||
selectedFiles = []
|
||||
pdfFilesInput.value = ''
|
||||
fileListDiv.innerHTML = ''
|
||||
fileListDiv.classList.add('hidden')
|
||||
convertBtn.disabled = true
|
||||
|
||||
setTimeout(() => {
|
||||
hideStatus()
|
||||
}, 3000)
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error creating ZIP:', error)
|
||||
showStatus(`❌ Error creating ZIP: ${error instanceof Error ? error.message : 'Unknown error'}`, 'error')
|
||||
}
|
||||
|
||||
} else if (e.data.status === 'error') {
|
||||
const errorMessage = e.data.message || 'Unknown error occurred in worker.';
|
||||
console.error('Worker Error:', errorMessage);
|
||||
showStatus(`❌ Worker Error: ${errorMessage}`, 'error');
|
||||
}
|
||||
};
|
||||
|
||||
if (backToToolsBtn) {
|
||||
backToToolsBtn.addEventListener('click', () => {
|
||||
window.location.href = '../../index.html#tools-header'
|
||||
window.location.href = '/'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user