const form = document.getElementById('licenseForm'); const status = document.getElementById('status'); form.addEventListener('submit', async (e) => { e.preventDefault(); status.textContent = "Генерация лицензии..."; const formData = new FormData(form); try { const response = await fetch('/api/generate', { method: 'POST', body: formData }); if (!response.ok) throw new Error(`Ошибка: ${response.statusText}`); const blob = await response.blob(); const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `Custom.mxtpro`; document.body.appendChild(a); a.click(); a.remove(); status.textContent = "Лицензия успешно сгенерирована!"; } catch (err) { console.error(err); status.textContent = "Ошибка генерации лицензии."; } });