-
Notifications
You must be signed in to change notification settings - Fork 11
/
script.js
56 lines (46 loc) · 2.02 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
document.addEventListener("DOMContentLoaded", function () {
const list = document.getElementById("list");
let attendees = [];
fetch('https://raw.githubusercontent.com/cocomo29/GitHub-Workshop/main/attendees.JSON')
.then(response => response.json())
.then(data => {
attendees = data.attendees;
displayAttendees(attendees);
})
.catch(error => {
console.error('Error fetching JSON file:', error);
});
function displayAttendees(attendees) {
attendees.forEach((attendee, index) => {
const listItem = document.createElement('div');
listItem.classList.add('col-md-3', 'mt-3');
const card = document.createElement('div');
card.classList.add('card', 'text-center');
const cardLink = document.createElement('a');
cardLink.href = `https://github.com/${attendee.username}`;
cardLink.target = '_blank'
cardLink.classList.add('card-link');
const cardHeader = document.createElement('div');
cardHeader.classList.add('card-header');
const cardNumber = document.createElement('small');
cardNumber.textContent = `${index + 1}`;
cardNumber.classList.add('card-number');
const cardBody = document.createElement('div');
cardBody.classList.add('card-body');
const cardTitle = document.createElement('h5');
cardTitle.classList.add('card-title');
cardTitle.textContent = attendee.name;
const universityName = document.createElement('small');
universityName.textContent = attendee.university;
universityName.classList.add('university-name')
cardHeader.appendChild(cardNumber);
cardBody.appendChild(cardTitle);
cardBody.appendChild(universityName);
card.appendChild(cardHeader);
card.appendChild(cardBody);
cardLink.appendChild(card);
listItem.appendChild(cardLink);
list.appendChild(listItem);
});
}
});