(e)
| 684 | } |
| 685 | |
| 686 | async function filesFromDropEvent(e) { |
| 687 | const dt = e.dataTransfer; |
| 688 | if (!dt) return []; |
| 689 | |
| 690 | if (dt.items && dt.items.length && typeof dt.items[0].webkitGetAsEntry === 'function') { |
| 691 | let out = []; |
| 692 | const entries = []; |
| 693 | for (let i = 0; i < dt.items.length; i++) { |
| 694 | const entry = dt.items[i].webkitGetAsEntry(); |
| 695 | if (entry) entries.push(entry); |
| 696 | } |
| 697 | for (let i = 0; i < entries.length; i++) { |
| 698 | const entry = entries[i]; |
| 699 | if (entry.isFile) { |
| 700 | const file = dt.items[i].getAsFile ? dt.items[i].getAsFile() : null; |
| 701 | if (file) { |
| 702 | out.push({ file, relativePath: file.name }); |
| 703 | } |
| 704 | continue; |
| 705 | } |
| 706 | const nested = await walkEntry(entry, ''); |
| 707 | out = out.concat(nested); |
| 708 | } |
| 709 | if (out.length) return out; |
| 710 | } |
| 711 | |
| 712 | return filesFromInputList(dt.files || []); |
| 713 | } |
| 714 | |
| 715 | if (chooseFilesBtn) { |
| 716 | chooseFilesBtn.addEventListener('click', function (e) { |
no test coverage detected