const queueBtn = document.getElementById('queue-btn'); const jobsContainer = document.getElementById('jobs-container'); let jobs = []; function renderJobs() { if (!jobsContainer) return; if (jobs.length === 0) { jobsContainer.innerHTML = ''; return; } jobsContainer.innerHTML = '
' + '

Pending jobs

' + '
'; } queueBtn?.addEventListener('click', async () => { const text = textInput.value; const toLanguage = toLangSelect.value; const model = modelSelect.value; const res = await fetch('/api/jobs', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text, toLanguage, model }), }); if (!res.ok) return; const { id } = await res.json(); jobs = [{ id, text, toLanguage, model }].concat(jobs); renderJobs(); });