Launch update methods asynchronously

This commit is contained in:
George Lacey 2022-04-11 08:41:32 +01:00
parent b6f204a15e
commit 1651b2f4ef

View File

@ -12,32 +12,38 @@ function colourRepo(repo_json, label, container_id) {
$(container_id).find(repoLabel).addClass(bg_class);
}
window.addEventListener("DOMContentLoaded", function () {
function stringRequests() {
$('[data-json-string-request]').each(function (index, element) {
$.getJSON($(this).attr("data-json-string-request"), function (data) {
console.log(index);
$(element).html(data['data']);
})
});
}
}, false);
window.addEventListener("DOMContentLoaded", function () {
function colourRepos() {
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);
})
});
})
}
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);
})
});
})
}
window.addEventListener("DOMContentLoaded", function () {
setTimeout(createGraphs, 0);
setTimeout(colourRepos, 0);
setTimeout(stringRequests, 0);
}, false);