Add visible file upload label button, inline JS diagnostic badge, update TS event handlers

This commit is contained in:
2026-05-13 17:09:33 +02:00
parent 0b47d81c51
commit 3432d362e2
4 changed files with 43 additions and 13 deletions

View File

@@ -156,9 +156,16 @@ el('video-select').addEventListener('change', function () {
selectedFilePath = this.value;
});
// ── File upload ───────────────────────────────────────
el('video-upload').addEventListener('change', function () {
if (this.files?.length)
const videoUpload = el('video-upload');
const uploadName = el('upload-name');
videoUpload.addEventListener('change', function () {
if (this.files?.length) {
selectedFilePath = null; // will upload on submit
uploadName.textContent = `Selected: ${this.files[0].name} (${formatSize(this.files[0].size)})`;
}
else {
uploadName.textContent = '';
}
});
// ── YouTube download ──────────────────────────────────
el('download-url').addEventListener('click', async () => {
@@ -189,10 +196,9 @@ el('download-url').addEventListener('click', async () => {
el('new-job-form').addEventListener('submit', async (e) => {
e.preventDefault();
if (!selectedFilePath) {
const fileEl = el('video-upload');
if (fileEl.files?.length) {
if (videoUpload.files?.length) {
const formData = new FormData();
formData.append('video', fileEl.files[0]);
formData.append('video', videoUpload.files[0]);
try {
const headers = {};
if (authToken)
@@ -262,7 +268,8 @@ el('new-job-form').addEventListener('submit', async (e) => {
});
await apiJson('POST', `/api/jobs/${data.job.id}/start`);
selectedFilePath = null;
el('video-upload').value = '';
videoUpload.value = '';
uploadName.textContent = '';
el('new-job-form').reset();
switchTab('dashboard');
}