MCPcopy Create free account
hub / github.com/MemeTray/MemeTray / processFiles

Function processFiles

tools/animation-compression/script.js:175–209  ·  view source on GitHub ↗
(files)

Source from the content-addressed store, hash-verified

173}
174
175async function processFiles(files) {
176 const progressContainer = document.getElementById('progressContainer');
177 const progressText = document.getElementById('progressText');
178 const progressPercent = document.getElementById('progressPercent');
179 const progressFill = document.getElementById('progressFill');
180 const batchActions = document.getElementById('batchActions');
181
182 progressContainer.style.display = 'block';
183 const totalFiles = files.length;
184 let processedCount = 0;
185
186 for (const fileObj of files) {
187 const reader = new FileReader();
188 await new Promise((resolve) => {
189 reader.onload = async (e) => {
190 await resizeGif(new Uint8Array(e.target.result), fileObj.file.name, fileObj.path);
191 processedCount++;
192
193 const percent = Math.round((processedCount / totalFiles) * 100);
194 progressText.textContent = `Processing: ${processedCount} / ${totalFiles}`;
195 progressPercent.textContent = `${percent}%`;
196 progressFill.style.width = `${percent}%`;
197
198 resolve();
199 };
200 reader.readAsArrayBuffer(fileObj.file);
201 });
202 }
203
204 progressContainer.style.display = 'none';
205 batchActions.style.display = 'flex';
206
207 // Detect duplicate files
208 checkDuplicates();
209}
210
211// Calculate a hash for the file contents
212async function calculateHash(blob) {

Callers 2

setupEventListenersFunction · 0.70
handleFilesFunction · 0.70

Calls 2

resizeGifFunction · 0.85
checkDuplicatesFunction · 0.85

Tested by

no test coverage detected