-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathscript.js
More file actions
71 lines (59 loc) · 3.22 KB
/
script.js
File metadata and controls
71 lines (59 loc) · 3.22 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
document.addEventListener("DOMContentLoaded", () => {
const attendeeList = document.getElementById("attendee-list");
const searchInput = document.getElementById("search");
// Function to load and parse markdown files from attendees.json
const loadAttendees = () => {
fetch("./attendees.json")
.then(response => response.json())
.then(markdownFiles => {
attendeeList.innerHTML = ""; // Clear current attendees
markdownFiles.forEach(file => {
fetch(file)
.then(response => response.text())
.then(text => {
const lines = text.split("\n");
const name = lines[0].replace("# ", "").trim();
const imageUrl = lines[1].replace("**Image:** ", "").trim();
const affiliation = lines[2].replace("**Affiliation:** ", "").trim();
const email = lines[3].replace("**Email:** ", "").trim();
const bio = lines.slice(5).join(" ").trim();
const attendeeCard = document.createElement("div");
attendeeCard.classList.add("attendee-card");
const attendeeImage = document.createElement("img");
attendeeImage.src = imageUrl;
attendeeImage.alt = `${name}'s image`;
const attendeeName = document.createElement("h2");
attendeeName.textContent = name;
const attendeeAffiliation = document.createElement("p");
attendeeAffiliation.textContent = `Affiliation: ${affiliation}`;
const attendeeEmail = document.createElement("p");
attendeeEmail.textContent = `Email: ${email}`;
const attendeeBio = document.createElement("p");
attendeeBio.textContent = bio;
attendeeCard.appendChild(attendeeImage);
attendeeCard.appendChild(attendeeName);
attendeeCard.appendChild(attendeeAffiliation);
attendeeCard.appendChild(attendeeEmail);
attendeeCard.appendChild(attendeeBio);
attendeeList.appendChild(attendeeCard);
})
.catch(error => {
console.error("Error loading markdown file:", error);
});
});
})
.catch(error => {
console.error("Error loading attendees.json:", error);
});
};
// Load attendees on page load
loadAttendees();
// Search functionality
searchInput.addEventListener("input", (e) => {
const query = e.target.value.toLowerCase();
document.querySelectorAll(".attendee-card").forEach(card => {
const name = card.querySelector("h2").textContent.toLowerCase();
card.style.display = name.includes(query) ? "block" : "none";
});
});
});