-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
134 lines (115 loc) · 4.54 KB
/
script.js
File metadata and controls
134 lines (115 loc) · 4.54 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
const hamburger = document.querySelector(".hamburger");
const navList = document.querySelector(".nav-list");
hamburger.addEventListener("click", () => {
hamburger.classList.toggle("active");
navList.classList.toggle("active");
});
document.querySelectorAll(".nav-link").forEach((n) =>
n.addEventListener("click", () => {
hamburger.classList.remove("active");
navList.classList.remove("active");
})
);
var speakers = [
{
name: "Sir Andrew Wiles",
profession: "Royal Society Research Professor at the University of Oxford",
image: "images/Andrew-Wiles.jpg",
achievement:
"Proved Fermat's Last Theorem and awarded the 2016 Abel Prize and the 2017 Copley Medal by the Royal Society. A Knight Commander of the Order of the British Empire. First Regius professor of mathematics at Oxford.",
},
{
name: "Luis Caffarelli",
profession: "Professor at the University of Texas, Austin",
image: "images/Caffarelli.jpg",
achievement:
"Currently holds the Sid Richardson Chair at the University of Texas at Austin. Named a SIAM Fellow in 2018 and received the Shaw Prize in Mathematics. Awarded the 2023 Abel Prize",
},
{
name: "John E Huh",
profession: "Professor at Princeton University",
image: "images/june-huh.jpg",
achievement:
"He was awarded the 2022 Fields Medal of the International Mathematical Union.",
},
{
name: "Terence Tao (The 'Mozart' of Mathematics)",
profession:
"Professor of mathematics at the University of California, Los Angeles",
image: "images/terence_tao.png",
achievement:
"Tao won the Fields Medal in 2006 and won the Royal Medal and Breakthrough Prize in Mathematics in 2014.",
},
{
name: "Cédric Patrice Thierry Villani",
profession: "French politician and mathematician.",
image: "images/Cedric1.jpg",
achievement:
"He was awarded the Fields Medal in 2010, and he was the director of Sorbonne University's Institut Henri Poincaré from 2009 to 2017.",
},
{
name: "Urmila Mahadev",
profession: "American mathematician and theoretical computer scientist",
image: "images/Urmilla.jpg",
achievement:
"Won the Machtey Award at the Symposium on Foundations of Computer Science in 2018, and in 2021 one of the three inaugural Maryam Mirzakhani New Frontiers Prizes for early-career achievements by women mathematicians.",
},
];
var speakersTitle = document.createElement("h3");
speakersTitle.classList.add("speakers-title");
speakersTitle.textContent = "Featured Speakers";
var featuredSpeakers = document.getElementById("featured-speakers");
featuredSpeakers.insertAdjacentElement("beforebegin", speakersTitle);
speakers.forEach(function (speaker) {
var speakerDetails = document.createElement("div");
speakerDetails.classList.add("speaker-details");
var imageContainer = document.createElement("div");
imageContainer.classList.add("speaker-img");
var imageElement = document.createElement("img");
imageElement.src = speaker.image;
imageElement.alt = speaker.name;
imageContainer.appendChild(imageElement);
speakerDetails.appendChild(imageContainer);
var speakerInfo = document.createElement("div");
speakerInfo.classList.add("speaker-info");
var nameElement = document.createElement("h4");
nameElement.textContent = speaker.name;
speakerInfo.appendChild(nameElement);
var professionElement = document.createElement("p");
professionElement.textContent = speaker.profession;
speakerInfo.appendChild(professionElement);
var achievementElement = document.createElement("p");
achievementElement.textContent = speaker.achievement;
speakerInfo.appendChild(achievementElement);
speakerDetails.appendChild(speakerInfo);
featuredSpeakers.appendChild(speakerDetails);
});
var moreButton = document.querySelector(".more-btn");
speakers = Array.from(document.querySelectorAll(".speaker-details"));
moreButton.addEventListener("click", function () {
speakers.slice(-4).forEach(function (speaker) {
speaker.classList.toggle("hidden");
});
if (moreButton.textContent === "More") {
moreButton.textContent = "Less";
} else {
moreButton.textContent = "More";
}
});
function hideSpeakers() {
if (window.innerWidth < 768) {
speakers.slice(-4).forEach(function (speaker) {
speaker.classList.add("hidden");
});
moreButton.textContent = "More";
} else {
speakers.forEach(function (speaker) {
speaker.classList.remove("hidden");
});
moreButton.textContent = "More";
}
}
hideSpeakers();
window.addEventListener("resize", function () {
hideSpeakers();
});