You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
966 B
JavaScript
26 lines
966 B
JavaScript
const reference = document.getElementById("reference");
|
|
const contributionsList = document.getElementById("contributions");
|
|
|
|
window.addEventListener("load", () => {
|
|
fetch("https://hub.xpub.nl/soupboat/atlas-api/contributions")
|
|
.then((response) => response.json())
|
|
.then((data) => populateContributions(data));
|
|
});
|
|
|
|
function populateContributions(contributions) {
|
|
contributions.forEach((contribution) => {
|
|
contributionsList.appendChild(createSection(contribution));
|
|
});
|
|
}
|
|
|
|
function createSection(contribution) {
|
|
let section = reference.cloneNode(true);
|
|
section.id = contribution.moment;
|
|
section.querySelector(".moment").innerHTML = contribution.moment;
|
|
section.querySelector(".title").innerHTML = contribution.title;
|
|
section.querySelector(".author").innerHTML = contribution.author;
|
|
section.querySelector(".description").innerHTML = contribution.description;
|
|
section.querySelector(".content").innerHTML = contribution.content_html;
|
|
return section;
|
|
}
|