()
| 4779 | } |
| 4780 | |
| 4781 | function triggerNextNonZipDownload() { |
| 4782 | const q = window.__nonZipDownloadQueue || []; |
| 4783 | if (!q.length) { |
| 4784 | hideNonZipPanel(); |
| 4785 | showToast( |
| 4786 | t('downloads_started') || 'All downloads started.', |
| 4787 | 'success' |
| 4788 | ); |
| 4789 | return; |
| 4790 | } |
| 4791 | |
| 4792 | const { folder, name, sourceId } = q.shift(); |
| 4793 | const url = apiFileUrl(folder || 'root', name, /* inline */ false, sourceId); |
| 4794 | |
| 4795 | const a = document.createElement('a'); |
| 4796 | a.href = url; |
| 4797 | a.download = name; |
| 4798 | a.style.display = 'none'; |
| 4799 | document.body.appendChild(a); |
| 4800 | |
| 4801 | try { |
| 4802 | a.click(); |
| 4803 | } finally { |
| 4804 | setTimeout(() => { |
| 4805 | if (a && a.parentNode) { |
| 4806 | a.parentNode.removeChild(a); |
| 4807 | } |
| 4808 | }, 500); |
| 4809 | } |
| 4810 | |
| 4811 | // Update queue + UI |
| 4812 | window.__nonZipDownloadQueue = q; |
| 4813 | if (q.length) { |
| 4814 | updateNonZipPanelText(); |
| 4815 | } else { |
| 4816 | hideNonZipPanel(); |
| 4817 | showToast( |
| 4818 | t('downloads_started') || 'All downloads started.', |
| 4819 | 'success' |
| 4820 | ); |
| 4821 | } |
| 4822 | } |
| 4823 | |
| 4824 | // Optional debug helpers if you want them globally: |
| 4825 | window.triggerNextNonZipDownload = triggerNextNonZipDownload; |
no test coverage detected