From 14daf96ca64f2582cd2bcc327e4e1c69d00b4a16 Mon Sep 17 00:00:00 2001 From: Verum Date: Thu, 5 Mar 2026 18:46:24 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=81=D0=BD=D0=BE=D0=B2=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F=20js=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/js/main.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 frontend/js/main.js diff --git a/frontend/js/main.js b/frontend/js/main.js new file mode 100644 index 0000000..2d98d10 --- /dev/null +++ b/frontend/js/main.js @@ -0,0 +1,32 @@ +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 = "Ошибка генерации лицензии."; + } +});