Implement reusable upload platform

This commit is contained in:
“Naeel”
2026-09-05 08:51:32 +03:00
parent 82d9ca9136
commit c0b87880ae
35 changed files with 734 additions and 9 deletions
+22
View File
@@ -0,0 +1,22 @@
import { esc } from './esc.js';
import { fs } from './fs.js';
export function render(state, elements) {
if (!state.files.length) {
elements.tableBodyEl.innerHTML = '<tr><td colspan="3">Нет выбранных файлов</td></tr>';
} else {
elements.tableBodyEl.innerHTML = state.files.map((file, index) => {
const over = state.overNames.has(file.name);
const status = over ? 'не учитывается (лимит)' : 'готов';
return `<tr id="row-${index}"><td>${esc(file.name)}</td>`
+ `<td>${fs(file.size)}</td><td id="st-${index}">${status}</td></tr>`;
}).join('');
}
const included = state.files.filter((file) => !state.overNames.has(file.name));
const overCount = state.files.length - included.length;
const size = included.reduce((total, file) => total + file.size, 0);
elements.countEl.textContent = `${included.length} учитываются`
+ (overCount ? ` + ${overCount} свыше лимита` : '')
+ ` · ${fs(size)}`;
elements.uploadBtnEl.disabled = included.length === 0;
}