-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
157 lines (140 loc) · 4.6 KB
/
script.js
File metadata and controls
157 lines (140 loc) · 4.6 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
const menukill = () => {
const mobilenav = document.getElementById('mobilenav');
if (mobilenav) {
mobilenav.style.width = '0';
}
const main = document.getElementById('main');
if (main) {
main.style.marginLeft = '0';
}
document.body.style.backgroundColor = 'rgba(255, 255, 255, 1)';
};
const closeMenu = () => {
menukill();
};
const menuopen = () => {
const mobilenav = document.getElementById('mobilenav');
if (mobilenav) {
mobilenav.style.width = '100%';
}
const main = document.getElementById('main');
if (main) {
main.style.marginLeft = '250px';
}
document.body.style.backgroundColor = 'rgba(0, 0, 0, 0.4)';
};
const menuToggle = document.getElementById('menu-toggle');
if (menuToggle) {
menuToggle.addEventListener('click', menuopen);
}
const closeMenuLinks = document.querySelectorAll('.close-menu');
if (closeMenuLinks) {
closeMenuLinks.forEach((link) => {
link.addEventListener('click', closeMenu);
});
}
// Featured Speakers
// Speakers array
const speakers = [
{
name: 'Mark Williams',
qualification: 'Masters in Instructional Design',
background: 'Seasoned instructional designer with expertise in developing innovative learning solutions.',
imageSrc: 'images/human1.svg',
},
{
name: 'Dr. Sophia Lee',
qualification: 'PhD in Education Technology',
background: 'Experienced researcher and educator specializing in the intersection of technology and learning.',
imageSrc: 'images/human2.svg',
},
{
name: 'Dr. Robert Chen',
qualification: 'Doctorate in Artificial Intelligence',
background: 'Renowned AI researcher and advocate for leveraging technology to enhance educational access and equity.',
imageSrc: 'images/human3.svg',
},
{
name: 'Sarah Johnson',
qualification: 'Masters in Educational Psychology',
background: 'Accomplished educational psychologist with a deep understanding of learner engagement and motivation.',
imageSrc: 'images/human4.svg',
},
{
name: 'Michael Thompson',
qualification: 'PhD in Education Technology',
background: 'Extensive experience in developing AI-powered tutoring systems',
imageSrc: 'images/human1.svg',
},
{
name: 'David Mitchell',
qualification: 'Masters in Computer Science',
background: 'Specializes in educational game development and immersive learning experiences',
imageSrc: 'images/human3.svg',
},
];
// Dynamic HTML
// Function to create the HTML dynamically for each speaker
const createSpeakerHTML = (speaker) => {
const speakerHTML = `
<div class='speakers-main'>
<img class='speakers-img' src='${speaker.imageSrc}' alt='image of speaker'>
<div class='speakers-info'>
<h5 class='speakers-name'>${speaker.name}</h5>
<p class='speakers-qualification'>${speaker.qualification}</p>
<p class='speakers-background'>${speaker.background}</p>
</div>
</div>
`;
return speakerHTML;
};
// Add the dynamic HTML to the HTML section
const addSpeakersToPage = () => {
const featuredSpeakersSection = document.getElementById('featured-speakers-section');
console.log(featuredSpeakersSection);
const speakersContainer = document.getElementById('speakers-container');
let speakersHTML = '';
let cuurentSpeakers = 2;
let allSpeakers;
// Update visibility of speakers
const updateVisibility = () => {
for (let i = 0; i < allSpeakers.length; i += 1) {
if (i < cuurentSpeakers) {
allSpeakers[i].style.display = 'flex';
} else {
allSpeakers[i].style.display = 'none';
}
}
};
// Iterate through each speaker in the data and create the HTML
for (let i = 0; i < speakers.length; i += 1) {
speakersHTML += createSpeakerHTML(speakers[i]);
}
speakersContainer.innerHTML = speakersHTML;
// Get all speaker elements
allSpeakers = speakersContainer.getElementsByClassName('speakers-main');
// Screen size display
const screenWidth = window.innerWidth;
if (screenWidth >= 768) {
// Show all speakers on desktop
for (let i = 0; i < allSpeakers.length; i += 1) {
allSpeakers[i].style.display = 'flex';
}
} else {
// Only speakers on mobile
updateVisibility();
}
// Listener to more button
const seeMoreButton = document.getElementById('see-more-button');
if (screenWidth < 768) {
seeMoreButton.style.display = 'block';
seeMoreButton.addEventListener('click', () => {
cuurentSpeakers += 2;
updateVisibility();
});
} else {
seeMoreButton.style.display = 'none';
}
};
document.addEventListener('DOMContentLoaded', addSpeakersToPage);
window.addEventListener('resize', addSpeakersToPage);