-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
135 lines (120 loc) · 4.24 KB
/
main.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
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
const speakers = [
{
name: 'James Oletik',
aboutem: 'Co-founder and CEO Club TT motorsport',
bio: 'A kenyan WRC racer and founder of clubTT motorsport with several won titles in WRC Championship',
id: 'first',
image: '/images/speaker1.png',
},
{
name: 'Mercy Kaptum',
aboutem: 'WRC racer',
bio: 'A Female kenyan WRC racer,that has put ladies on the rally map in her outstanding perfomance last year',
id: 'second',
image: '/images/speaker2.png',
},
{
name: 'Parsali Olerek',
aboutem: 'Retired WRC racer',
bio: 'A former WRC racer and 2021,WRC winner,Currently lead coach in Kenya Airways rally team',
id: 'third',
image: '/images/speaker3.png',
},
{
name: 'Peter Opondo',
aboutem: 'Mechanic and race car-tuner',
bio: 'A kenyan Mechanic that has specialised in tuning cars to peek performance for rally-purposes',
id: 'fourth',
image: '/images/speaker4.png',
},
{
name: 'Sam Hamilton',
aboutem: 'Co-founder and CEO Sunset GT ',
bio: 'A kenyan enthusiast that has specialised in tuning cars to peek performance for rally-purposes',
id: 'fifth',
image: '/images/speaker5.png',
},
{
name: 'Jeff Onsense',
aboutem: 'Co-founder and CEO Sport Nation_254',
bio: 'A kenyan WRC racer and founder of Sport Nation_254,Famous for his many won titles in drag races in Kenya',
id: 'sixth',
image: '/images/speaker6.png',
},
];
const featuredSpeakers = document.querySelector('.featured-speakers');
const speakersTop = document.createElement('div');
speakersTop.classList.add('speakers_top');
featuredSpeakers.appendChild(speakersTop);
const header = document.createElement('h3');
header.innerHTML = 'Featured Speakers';
speakersTop.append(header);
const indicator = document.createElement('div');
indicator.classList.add('indicator');
featuredSpeakers.append(indicator);
const speakerList = document.createElement('div');
speakerList.classList.add('speaker-list');
featuredSpeakers.append(speakerList);
let temporary = '';
function loadSpeakers() {
temporary = '';
if (window.screen.width < 768) {
for (let i = 0; i < 2; i += 1) {
temporary += `<div id="${speakers[i].id}" class="speaker">
<div class="photo-bg"><img src="${speakers[i].image}" alt="Image of the speaker"></div>
<div class="speaker-details">
<h5>${speakers[i].name}</h5>
<p class="about-em">${speakers[i].aboutem}</p>
<p class="bio" >${speakers[i].bio}</p>
</div>
</div>`;
}
speakerList.innerHTML = temporary;
const showMore = document.createElement('div');
showMore.classList.add('show-container');
speakerList.appendChild(showMore);
const btnShow = document.createElement('button');
btnShow.setAttribute('id', 'showMore');
btnShow.innerHTML = 'More';
showMore.append(btnShow);
const span = document.createElement('span');
span.innerHTML = '▼';
btnShow.appendChild(span);
btnShow.addEventListener('click', () => {
temporary = '';
speakers.forEach((speaker) => {
temporary += `<div id="${speaker.id}" class="speaker">
<div class="photo-bg"><img src="${speaker.image}" alt="Image of the speaker"></div>
<div class="speaker-details">
<h5>${speaker.name}</h5>
<p class="about-em">${speaker.aboutem}</p>
<p class="bio" >${speaker.bio}</p>
</div>
</div>`;
});
speakerList.innerHTML = temporary;
});
} else {
speakers.forEach((speaker) => {
temporary += `<div id="${speaker.id}" class="speaker">
<div class="photo-bg"><img src="${speaker.image}" alt="Image of the speaker"></div>
<div class="speaker-details">
<h5>${speaker.name}</h5>
<p class="about-em">${speaker.aboutem}</p>
<p class="bio" >${speaker.bio}</p>
</div>
</div>`;
});
speakerList.innerHTML = temporary;
}
}
// button show more
// onloads
window.onload = function () {
temporary = '';
loadSpeakers();
};
window.onresize = function () {
temporary = '';
loadSpeakers();
};