()
| 127 | } |
| 128 | |
| 129 | function currentSelection() { |
| 130 | const checks = Array.from(document.querySelectorAll('#fileList .file-checkbox')); |
| 131 | // checkbox values are ESCAPED names (because buildFileTableRow used safeFileName) |
| 132 | const selectedEsc = checks.filter(cb => cb.checked).map(cb => cb.value); |
| 133 | const escSet = new Set(selectedEsc); |
| 134 | |
| 135 | // map back to real file objects by comparing escaped(f.name) |
| 136 | const files = fileData.filter(f => escSet.has(escapeHTML(f.name))); |
| 137 | |
| 138 | const any = files.length > 0; |
| 139 | const one = files.length === 1; |
| 140 | const many = files.length > 1; |
| 141 | const anyZip = files.some(f => isArchiveFileName(f.name)); |
| 142 | const file = one ? files[0] : null; |
| 143 | const canEditFlag = !!(file && canEditFile(file.name)); |
| 144 | |
| 145 | const caps = window.currentFolderCaps || null; |
| 146 | const inEncrypted = !!(caps && caps.encryption && caps.encryption.encrypted); |
| 147 | const allowShare = !inEncrypted && (caps ? !!(caps.canShareFile || caps.canShare) : true); |
| 148 | const allowLink = caps ? !!(caps.canView || caps.canViewOwn) : true; |
| 149 | const allowExtractZip = !inEncrypted && (caps ? !!caps.canExtract : true); |
| 150 | const allowZip = !inEncrypted; // zip-create is blocked inside encrypted folders |
| 151 | |
| 152 | // also return the raw names if any caller needs them |
| 153 | return { |
| 154 | files, // <— real file objects for modals |
| 155 | all: files.map(f => f.name), |
| 156 | any, one, many, anyZip, |
| 157 | file, |
| 158 | canEdit: canEditFlag, |
| 159 | allowLink, |
| 160 | allowShare, |
| 161 | allowZip, |
| 162 | allowExtractZip |
| 163 | }; |
| 164 | } |
| 165 | |
| 166 | export function fileListContextMenuHandler(e) { |
| 167 | e.preventDefault(); |
no test coverage detected