Call methods asynchronously

This commit is contained in:
George Lacey 2022-04-11 09:04:16 +01:00
parent 9ec5b178ac
commit b743b7919c

View File

@ -20,30 +20,28 @@ function stringRequests() {
}); });
} }
function colourRepos() { function colourRepos(repo_list) {
const container = $('#repo-container'); const container = $('#repo-container');
$.getJSON(`/repo-list.json`, function (repo_list) { repo_list.labels.forEach(function (repo_label) {
repo_list.labels.forEach(function (repo_label) { $.getJSON(`/repo/${repo_label}.json`, function (repo_json) {
$.getJSON(`/repo/${repo_label}.json`, function (repo_json) { colourRepo(repo_json, repo_label, container);
colourRepo(repo_json, repo_label, container); })
}) });
});
})
} }
function createGraphs() { function createGraphs(repo_list) {
$.getJSON(`/repo-list.json`, function (repo_list) { repo_list.labels.forEach(function (repo_label) {
repo_list.labels.forEach(function (repo_label) { $.getJSON(`/repo/${repo_label}/monthly-size.json`, function (repo_size_json) {
$.getJSON(`/repo/${repo_label}/monthly-size.json`, function (repo_size_json) { draw_time_series_graph(`repo-${repo_label}-size-graph`, repo_size_json.repo,
draw_time_series_graph(`repo-${repo_label}-size-graph`, repo_size_json.repo, repo_size_json.dates, repo_size_json.units);
repo_size_json.dates, repo_size_json.units); })
}) });
});
})
} }
window.addEventListener("DOMContentLoaded", function () { window.addEventListener("DOMContentLoaded", function () {
setTimeout(createGraphs, 0);
setTimeout(colourRepos, 0);
setTimeout(stringRequests, 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); }, false);