From 8e92237fec70e716c53fd02d07d71c26faccddf5 Mon Sep 17 00:00:00 2001 From: Vladislav Moiseev Date: Sat, 8 Jul 2023 10:18:50 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D0=BE=D0=BA=D0=B0=D0=B7=D0=B0=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/index.html | 5 +++++ static/site.js | 12 +++++++++++- static/style.css | 11 +++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/static/index.html b/static/index.html index d572773..fd3635f 100644 --- a/static/index.html +++ b/static/index.html @@ -46,6 +46,11 @@
+
+
+ Загрузка... +
+
Результат
diff --git a/static/site.js b/static/site.js index 1e351e9..40001a3 100644 --- a/static/site.js +++ b/static/site.js @@ -27,15 +27,25 @@ const processAnalyzeResult = (data) => { for (const [query, result] of Object.entries(data.data.response)) { queriesResult.innerHTML += renderResultMarkup(query, result); } + } else if (data.data && data.data.error) { + queriesResult.innerHTML = `
${JSON.stringify(data.data.error)}
`; } }; const handleFormSubmit = (event) => { event.preventDefault(); const data = new FormData(event.target); + const loaderWrapper = document.getElementById('loaderWrapper'); + loaderWrapper.classList.remove('d-none'); fetch('/analyze', { method: 'POST', body: data }) .then((res) => res.json()) - .then(processAnalyzeResult); + .then(processAnalyzeResult) + .catch(() => { + alert('Произошла внутренняя ошибка.'); + }) + .finally(() => { + loaderWrapper.classList.add('d-none'); + }); }; document.addEventListener('DOMContentLoaded', () => { diff --git a/static/style.css b/static/style.css index e69de29..85fa2cf 100644 --- a/static/style.css +++ b/static/style.css @@ -0,0 +1,11 @@ +#loaderWrapper { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + background-color: #33333333; + display: flex; + justify-content: center; + align-items: center; +}