-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
43 lines (36 loc) · 1.35 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//Keep reference to all circle types in case we want to update later
let circleTypes = [];
fetch("//ergast.com/api/f1/current/constructorStandings.json")
.then(response => response.json())
.then(data => {
const standings = data.MRData.StandingsTable.StandingsLists;
const standingsContainer = document.querySelector(".standings-container");
//console.log("Standnings", standings);
standings[0].ConstructorStandings.forEach(team => {
insertTeam(
standingsContainer,
team.Constructor.name,
team.position,
team.points,
team.Constructor.constructorId);
//console.log(team.Constructor.constructorId);
});
});
const insertTeam = (container, team, position, points, id) => {
const template = `
<div class="team-container">
<h2 class="team-name ${id}-ct">${team}</h2>
<div class="circle-shape ${id}">
<p class="team-place">${position}</p>
<p class="team-points">${points} Points</p>
</div>
</div>`;
container.insertAdjacentHTML("beforeend", template);
addCircleType(id);
}
const addCircleType = (query) => {
const text = document.querySelector(`.${query}-ct`);
const span = document.querySelectorAll("span");
let circle = new CircleType(text).radius(180);
circleTypes.push(circle);
};