fetch data from the atlas api

master
km0 2 years ago
parent 7935d3a8da
commit 8fd15a86d2

@ -0,0 +1,25 @@
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;
}

@ -1,43 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Emergent Opera</title>
</head>
<body>
<div class="container">
<div class="atlas">
the atlas here
<div class="info">
<div class="title">Title</div>
<div class="filename">Filename.mp3</div>
<div class="position">04:35</div>
</div>
</div>
<div class="libretto">
<header class="cover">
<h3>SI18 Weekly Release #3</h3>
<h1>Emergent Opera</h1>
<p>description</p>
<h3>contribution by: <br> Kimberley, Chae, Kamo, Supi, Emma, Miri, Carmen, Alex, Gersande</h3>
<h3>caretakers: <br> Erica, Gersande, Kamo</h3>
</header>
<section class="index"></section>
<section class="contribution">
<h4>overture</h4>
<h1 class="title">Overture Atlas</h1>
<h3>description</h3>
<p>the whole description</p>
<h3>contents</h3>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<script src="contents.js" defer></script>
<title>Emergent Opera</title>
</head>
<body>
<div class="container">
<div class="atlas">
the atlas here
<div class="info">
<div class="title">Title</div>
<div class="filename">Filename.mp3</div>
<div class="position">04:35</div>
</div>
</div>
<div class="libretto">
<header class="cover">
<h3>SI18 Weekly Release #3</h3>
<h1>Emergent Opera</h1>
<p>description</p>
<h3>
contribution by: <br />
Kimberley, Chae, Kamo, Supi, Emma, Miri, Carmen, Alex, Gersande
</h3>
<h3>
caretakers: <br />
Erica, Gersande, Kamo
</h3>
</header>
<section class="index"></section>
<div class="contributions" id="contributions">
<!-- <section class="contribution">
<div class="moment">overture</div>
<h2 class="title">Overture Atlas</h2>
<div class="description">description</div>
<p>the whole description</p>
<h3>contents</h3>
</section> -->
</div>
</section>
<!-- <section class="vocabulary"></section> -->
</div>
</div>
</body>
</html>
<!-- this is a reference for the js script, hidden by default with css -->
<section class="contribution" id="reference">
<div class="moment">overture</div>
<h2 class="title">Overture Atlas</h2>
<div class="author"></div>
<div class="description">description</div>
<div class="content"></div>
</section>
<!-- <section class="vocabulary"></section> -->
</div>
</div>
</body>
</html>

@ -39,7 +39,6 @@ body{
.libretto{
overflow-y: scroll;
}
.libretto > * {
@ -48,9 +47,9 @@ body{
h3{
font-weight: normal;
}
h4{
.moment{
text-transform: uppercase;
font-weight: normal;
}
header{
@ -62,6 +61,10 @@ header{
display: none;
}
section{
/* section {
height: 100vh;
} */
#reference {
display: none;
}
Loading…
Cancel
Save