From b743b7919c187fcd4ddf123bdebb0800c6cc124e Mon Sep 17 00:00:00 2001 From: George Lacey Date: Mon, 11 Apr 2022 09:04:16 +0100 Subject: [PATCH] Call methods asynchronously --- borgweb/borg/static/borg/js/index.js | 36 +++++++++++++--------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/borgweb/borg/static/borg/js/index.js b/borgweb/borg/static/borg/js/index.js index 36434fc..087e478 100644 --- a/borgweb/borg/static/borg/js/index.js +++ b/borgweb/borg/static/borg/js/index.js @@ -20,30 +20,28 @@ function stringRequests() { }); } -function colourRepos() { +function colourRepos(repo_list) { const container = $('#repo-container'); - $.getJSON(`/repo-list.json`, function (repo_list) { - repo_list.labels.forEach(function (repo_label) { - $.getJSON(`/repo/${repo_label}.json`, function (repo_json) { - colourRepo(repo_json, repo_label, container); - }) - }); - }) + repo_list.labels.forEach(function (repo_label) { + $.getJSON(`/repo/${repo_label}.json`, function (repo_json) { + colourRepo(repo_json, repo_label, container); + }) + }); } -function createGraphs() { - $.getJSON(`/repo-list.json`, function (repo_list) { - repo_list.labels.forEach(function (repo_label) { - $.getJSON(`/repo/${repo_label}/monthly-size.json`, function (repo_size_json) { - draw_time_series_graph(`repo-${repo_label}-size-graph`, repo_size_json.repo, - repo_size_json.dates, repo_size_json.units); - }) - }); - }) +function createGraphs(repo_list) { + repo_list.labels.forEach(function (repo_label) { + $.getJSON(`/repo/${repo_label}/monthly-size.json`, function (repo_size_json) { + draw_time_series_graph(`repo-${repo_label}-size-graph`, repo_size_json.repo, + repo_size_json.dates, repo_size_json.units); + }) + }); } window.addEventListener("DOMContentLoaded", function () { - setTimeout(createGraphs, 0); - setTimeout(colourRepos, 0); setTimeout(stringRequests, 0); + $.getJSON(`/repo-list.json`, function (repo_list) { + setTimeout(createGraphs.bind(null, repo_list), 0); + setTimeout(colourRepos.bind(null, repo_list), 0); + }); }, false);