|
185 | 185 | return breadcrumbEl; |
186 | 186 | } |
187 | 187 |
|
188 | | - |
189 | 188 | async function forceDownload(url, fileName) { |
190 | | - const button = document.querySelector(`a.download-button[href="${url}"]`); |
| 189 | + const button = document.querySelector(`a.download-button[data-url="${url}"]`); |
191 | 190 | if (!button) return; |
192 | 191 |
|
193 | 192 | const originalText = button.textContent; |
|
212 | 211 | console.error('Erro no download:', error); |
213 | 212 | alert('Falha no download. Verifique o console para mais detalhes.'); |
214 | 213 | } finally { |
215 | | - button.textContent = originalText; |
216 | | - button.style.pointerEvents = 'auto'; |
| 214 | + if (button) { |
| 215 | + button.textContent = originalText; |
| 216 | + button.style.pointerEvents = 'auto'; |
| 217 | + } |
217 | 218 | } |
218 | 219 | } |
219 | 220 |
|
|
266 | 267 | <td>${fileName}</td> |
267 | 268 | <td><em>${description || 'Arquivo'}</em></td> |
268 | 269 | <td style="text-align: right;"> |
269 | | - <a href="${downloadUrl}" class="download-button" data-filename="${fileName}">Download</a> |
| 270 | + <a href="#" class="download-button" data-url="${downloadUrl}" data-filename="${fileName}">Download</a> |
270 | 271 | </td> |
271 | 272 | </tr>`; |
272 | 273 | } |
|
287 | 288 | contentArea.querySelectorAll('.download-button[data-filename]').forEach(button => { |
288 | 289 | button.addEventListener('click', e => { |
289 | 290 | e.preventDefault(); |
290 | | - forceDownload(e.target.href, e.target.dataset.filename); |
| 291 | + forceDownload(e.target.dataset.url, e.target.dataset.filename); |
291 | 292 | }); |
292 | 293 | }); |
293 | 294 | } |
|
347 | 348 | <td>${file.name}</td> |
348 | 349 | <td>${file.description}</td> |
349 | 350 | <td><a href="#" class="dir-link" data-path="${file.path}">${file.path || 'home'}/</a></td> |
350 | | - <td style="text-align: right;"><a href="${downloadUrl}" class="download-button" data-filename="${file.name}">Download</a></td> |
| 351 | + <td style="text-align: right;"><a href="#" class="download-button" data-url="${downloadUrl}" data-filename="${file.name}">Download</a></td> |
351 | 352 | `; |
352 | 353 | resultsBody.appendChild(row); |
353 | 354 | } |
|
363 | 364 | resultsBody.querySelectorAll('.download-button[data-filename]').forEach(button => { |
364 | 365 | button.addEventListener('click', e => { |
365 | 366 | e.preventDefault(); |
366 | | - forceDownload(e.target.href, e.target.dataset.filename); |
| 367 | + forceDownload(e.target.dataset.url, e.target.dataset.filename); |
367 | 368 | }); |
368 | 369 | }); |
369 | 370 | } |
370 | | - |
| 371 | + |
371 | 372 | searchInput.addEventListener('input', (e) => { |
372 | 373 | const query = e.target.value.trim(); |
373 | 374 | if (query) { |
|
0 commit comments