(files)
| 89 | } |
| 90 | |
| 91 | async function processFiles(files) { |
| 92 | const progressContainer = document.getElementById('progressContainer'); |
| 93 | const progressText = document.getElementById('progressText'); |
| 94 | const progressPercent = document.getElementById('progressPercent'); |
| 95 | const progressFill = document.getElementById('progressFill'); |
| 96 | const batchActions = document.getElementById('batchActions'); |
| 97 | const statsContainer = document.getElementById('statsContainer'); |
| 98 | |
| 99 | progressContainer.style.display = 'block'; |
| 100 | const totalFiles = files.length; |
| 101 | let processedCount = 0; |
| 102 | |
| 103 | for (const fileObj of files) { |
| 104 | try { |
| 105 | // Compute the content hash |
| 106 | const hash = await calculatePixelHash(fileObj.file); |
| 107 | |
| 108 | // Create a preview URL |
| 109 | const url = URL.createObjectURL(fileObj.file); |
| 110 | |
| 111 | allFiles.push({ |
| 112 | id: fileIdCounter++, |
| 113 | name: fileObj.file.name, |
| 114 | path: fileObj.path, |
| 115 | size: fileObj.file.size, |
| 116 | hash: hash, |
| 117 | url: url, |
| 118 | file: fileObj.file |
| 119 | }); |
| 120 | |
| 121 | processedCount++; |
| 122 | const percent = Math.round((processedCount / totalFiles) * 100); |
| 123 | progressText.textContent = `Analyzing: ${processedCount} / ${totalFiles}`; |
| 124 | progressPercent.textContent = `${percent}%`; |
| 125 | progressFill.style.width = `${percent}%`; |
| 126 | } catch (error) { |
| 127 | console.error('Error processing file:', fileObj.file.name, error); |
| 128 | processedCount++; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | progressContainer.style.display = 'none'; |
| 133 | batchActions.style.display = 'flex'; |
| 134 | statsContainer.style.display = 'grid'; |
| 135 | |
| 136 | // Reset the file input so the same folder can be selected again |
| 137 | document.getElementById('fileInput').value = ''; |
| 138 | |
| 139 | analyzeAndDisplay(); |
| 140 | } |
| 141 | |
| 142 | function analyzeAndDisplay() { |
| 143 | const hashMap = new Map(); |
nothing calls this directly
no test coverage detected