(file, container)
| 1107 | |
| 1108 | /* -------------------------------- Small display helper -------------------------------- */ |
| 1109 | export function displayFilePreview(file, container) { |
| 1110 | const actualFile = file.file || file; |
| 1111 | if (!(actualFile instanceof File)) { |
| 1112 | console.error("displayFilePreview called with an invalid file object"); |
| 1113 | return; |
| 1114 | } |
| 1115 | container.style.display = "inline-block"; |
| 1116 | while (container.firstChild) container.removeChild(container.firstChild); |
| 1117 | |
| 1118 | if (IMG_RE.test(actualFile.name)) { |
| 1119 | const img = document.createElement("img"); |
| 1120 | img.src = URL.createObjectURL(actualFile); |
| 1121 | img.classList.add("file-preview-img"); |
| 1122 | container.appendChild(img); |
| 1123 | } else { |
| 1124 | const iconSpan = document.createElement("span"); |
| 1125 | iconSpan.classList.add("material-icons", "file-icon"); |
| 1126 | iconSpan.textContent = "insert_drive_file"; |
| 1127 | container.appendChild(iconSpan); |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | // expose for HTML onclick usage |
| 1132 | window.previewFile = previewFile; |
no outgoing calls
no test coverage detected