|
|
|
@ -1,20 +1,26 @@
|
|
|
|
|
let source_url = ""
|
|
|
|
|
let seatRef = document.getElementById("seatRef")
|
|
|
|
|
let partyRef = document.getElementById("partyRef")
|
|
|
|
|
let seatRef = document.querySelector(".seat")
|
|
|
|
|
let hemicycle = document.getElementsByClassName("hemicycle")[0]
|
|
|
|
|
let row = 5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fetch("https://hub.xpub.nl/soupboat/the-parliament/")
|
|
|
|
|
.then((response) => response.json())
|
|
|
|
|
.then((data) => {
|
|
|
|
|
source_url = data.base_url;
|
|
|
|
|
populateSeats(data.files)
|
|
|
|
|
populateSeats(data.parliament)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function populateSeats(representatives) {
|
|
|
|
|
for (const representative of representatives){
|
|
|
|
|
function populateSeats(parliament) {
|
|
|
|
|
for (const group of Object.keys(parliament)){ //gets the parent's keys
|
|
|
|
|
let party = partyRef.cloneNode(true);
|
|
|
|
|
party.id = group
|
|
|
|
|
for (representative of parliament[group]){
|
|
|
|
|
let seat = seatRef.cloneNode(true);
|
|
|
|
|
seat.querySelector(".label").innerHTML = representative.who;
|
|
|
|
|
seat.id = representative.who;
|
|
|
|
|
let filename = source_url + representative.filename;
|
|
|
|
|
let filename = source_url + group + '/' + representative.filename;
|
|
|
|
|
let audio = new Audio(filename)
|
|
|
|
|
audio.addEventListener("canplaythrough", (e) => {
|
|
|
|
|
console.log(filename);
|
|
|
|
@ -37,8 +43,21 @@ function populateSeats(representatives) {
|
|
|
|
|
mic.innerHTML = "Talk Again"
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
hemicycle.appendChild(seat);
|
|
|
|
|
party.appendChild(seat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hemicycle.appendChild(party);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
TODO
|
|
|
|
|
- upload svg
|
|
|
|
|
- loop through the elements to associate seat to each of them
|
|
|
|
|
- create label
|
|
|
|
|
- rotation?
|
|
|
|
|
*/
|