From dfded0e4de55f36ee26d13be8de5a36a2e3223ca Mon Sep 17 00:00:00 2001 From: Elizaveta Vinogradova Date: Tue, 28 Apr 2026 18:00:57 +0500 Subject: [PATCH 1/5] 1 task --- .idea/.gitignore | 10 ++++++++++ .idea/async.iml | 8 ++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ static/focus.js | 24 +++++++++++------------- 5 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/async.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/async.iml b/.idea/async.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/async.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7eaaa98 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/static/focus.js b/static/focus.js index 4b43735..4534981 100644 --- a/static/focus.js +++ b/static/focus.js @@ -5,8 +5,8 @@ const API = { buhForms: "/api3/buh", }; -function run() { - sendRequest(API.organizationList, (orgOgrns) => { +async function run() { + await sendRequest(API.organizationList, (orgOgrns) => { const ogrns = orgOgrns.join(","); sendRequest(`${API.orgReqs}?ogrn=${ogrns}`, (requisites) => { const orgsMap = reqsToMap(requisites); @@ -24,18 +24,16 @@ function run() { run(); function sendRequest(url, callback) { - const xhr = new XMLHttpRequest(); - xhr.open("GET", url, true); - - xhr.onreadystatechange = function () { - if (xhr.readyState === XMLHttpRequest.DONE) { - if (xhr.status === 200) { - callback(JSON.parse(xhr.response)); + return new Promise((resolve, reject) => { + const xhr = new XMLHttpRequest(); + xhr.open("GET", url, true); + xhr.onreadystatechange = function () { + if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) { + callback(JSON.parse(xhr.response)); } - } - }; - - xhr.send(); + }; + xhr.send(); + }) } function reqsToMap(requisites) { From 11637488af2d91982df0fbed74cceff47c88eda3 Mon Sep 17 00:00:00 2001 From: Elizaveta Vinogradova Date: Tue, 28 Apr 2026 18:16:27 +0500 Subject: [PATCH 2/5] 2 task --- static/focus.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/static/focus.js b/static/focus.js index 4534981..a06b947 100644 --- a/static/focus.js +++ b/static/focus.js @@ -24,16 +24,9 @@ async function run() { run(); function sendRequest(url, callback) { - return new Promise((resolve, reject) => { - const xhr = new XMLHttpRequest(); - xhr.open("GET", url, true); - xhr.onreadystatechange = function () { - if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) { - callback(JSON.parse(xhr.response)); - } - }; - xhr.send(); - }) + return fetch(url) + .then(res => res.json()) + .then(data => callback(data)); } function reqsToMap(requisites) { From 4d1468b065ee8ce8bcb3c686af9fab8886a6061e Mon Sep 17 00:00:00 2001 From: Elizaveta Vinogradova Date: Tue, 28 Apr 2026 18:24:47 +0500 Subject: [PATCH 3/5] sdf --- static/focus.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/static/focus.js b/static/focus.js index a06b947..7a0f9a8 100644 --- a/static/focus.js +++ b/static/focus.js @@ -11,7 +11,7 @@ async function run() { sendRequest(`${API.orgReqs}?ogrn=${ogrns}`, (requisites) => { const orgsMap = reqsToMap(requisites); sendRequest(`${API.analytics}?ogrn=${ogrns}`, (analytics) => { - addInOrgsMap(orgsMap, analytics, "analytics"); + addInOrgsMap(orgsMap, analytics, "analitics"); sendRequest(`${API.buhForms}?ogrn=${ogrns}`, (buh) => { addInOrgsMap(orgsMap, buh, "buhForms"); render(orgsMap, orgOgrns); @@ -26,7 +26,12 @@ run(); function sendRequest(url, callback) { return fetch(url) .then(res => res.json()) - .then(data => callback(data)); + .then(data => { + if (data["ok"] != true){ + alert(data[]) + }) + callback(data)) + } } function reqsToMap(requisites) { From 5695ae07539f51bb8c57958569a020892aec876d Mon Sep 17 00:00:00 2001 From: Elizaveta Vinogradova Date: Tue, 28 Apr 2026 18:53:23 +0500 Subject: [PATCH 4/5] 3 task --- static/focus.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/static/focus.js b/static/focus.js index 7a0f9a8..1d0453a 100644 --- a/static/focus.js +++ b/static/focus.js @@ -11,7 +11,7 @@ async function run() { sendRequest(`${API.orgReqs}?ogrn=${ogrns}`, (requisites) => { const orgsMap = reqsToMap(requisites); sendRequest(`${API.analytics}?ogrn=${ogrns}`, (analytics) => { - addInOrgsMap(orgsMap, analytics, "analitics"); + addInOrgsMap(orgsMap, analytics, "analytics"); sendRequest(`${API.buhForms}?ogrn=${ogrns}`, (buh) => { addInOrgsMap(orgsMap, buh, "buhForms"); render(orgsMap, orgOgrns); @@ -25,15 +25,15 @@ run(); function sendRequest(url, callback) { return fetch(url) - .then(res => res.json()) - .then(data => { - if (data["ok"] != true){ - alert(data[]) - }) - callback(data)) - } + .then(res =>{if (!res.ok){ + throw new Error(`${res.status} ${res.statusText}`); + }else{ + return res.json().then(data => callback(data)); + }}).catch(error => alert(error)); + } + function reqsToMap(requisites) { return requisites.reduce((acc, item) => { acc[item.ogrn] = item; From fa0bde6e1959d87ca7c5a0405806b5eec72307cf Mon Sep 17 00:00:00 2001 From: Elizaveta Vinogradova Date: Tue, 28 Apr 2026 19:20:15 +0500 Subject: [PATCH 5/5] 4 task --- static/focus.js | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/static/focus.js b/static/focus.js index 1d0453a..bfcc04c 100644 --- a/static/focus.js +++ b/static/focus.js @@ -6,30 +6,33 @@ const API = { }; async function run() { - await sendRequest(API.organizationList, (orgOgrns) => { - const ogrns = orgOgrns.join(","); - sendRequest(`${API.orgReqs}?ogrn=${ogrns}`, (requisites) => { - const orgsMap = reqsToMap(requisites); - sendRequest(`${API.analytics}?ogrn=${ogrns}`, (analytics) => { - addInOrgsMap(orgsMap, analytics, "analytics"); - sendRequest(`${API.buhForms}?ogrn=${ogrns}`, (buh) => { - addInOrgsMap(orgsMap, buh, "buhForms"); - render(orgsMap, orgOgrns); - }); - }); - }); - }); + const orgOgrns = await sendRequest(API.organizationList, o=>o); + const ogrns = orgOgrns.join(","); + + const [requisites, analytics, buh] + = await Promise.all([ + sendRequest(`${API.orgReqs}?ogrn=${ogrns}`, o=>o), + sendRequest(`${API.analytics}?ogrn=${ogrns}`, o=>o), + sendRequest(`${API.buhForms}?ogrn=${ogrns}`, o=>o)] + ); + const orgsMap = reqsToMap(requisites); + addInOrgsMap(orgsMap, analytics, "analytics"); + addInOrgsMap(orgsMap, buh, "buhForms"); + render(orgsMap, orgOgrns); + } run(); function sendRequest(url, callback) { return fetch(url) - .then(res =>{if (!res.ok){ - throw new Error(`${res.status} ${res.statusText}`); - }else{ - return res.json().then(data => callback(data)); - }}).catch(error => alert(error)); + .then(res => { + if (!res.ok) { + throw new Error(`${res.status} ${res.statusText}`); + } else { + return res.json().then(data => callback(data)); + } + }).catch(error => alert(error)); } @@ -82,7 +85,7 @@ function renderOrganization(orgInfo, template, container) { orgInfo.buhForms[orgInfo.buhForms.length - 1].form2[0] && orgInfo.buhForms[orgInfo.buhForms.length - 1].form2[0] .endValue) || - 0 + 0 ); } else { money.textContent = "—";