forked from eldemet/CYAIC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
377 lines (342 loc) · 14.3 KB
/
script.js
File metadata and controls
377 lines (342 loc) · 14.3 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
// Smooth scrolling for navigation links
document.addEventListener('DOMContentLoaded', function() {
// Navigation functionality
const navLinks = document.querySelectorAll('.nav-link');
navLinks.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetSection = document.querySelector(targetId);
if (targetSection) {
targetSection.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Active navigation highlighting
function updateActiveNav() {
const sections = document.querySelectorAll('.section');
const navLinks = document.querySelectorAll('.nav-link');
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (window.pageYOffset >= sectionTop - 200) {
current = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === '#' + current) {
link.classList.add('active');
}
});
}
// Scroll to top button
const scrollToTopBtn = document.createElement('button');
scrollToTopBtn.innerHTML = '↑';
scrollToTopBtn.className = 'scroll-to-top';
scrollToTopBtn.setAttribute('aria-label', 'Scroll to top');
document.body.appendChild(scrollToTopBtn);
scrollToTopBtn.addEventListener('click', function() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
// Show/hide scroll to top button
function toggleScrollToTop() {
if (window.pageYOffset > 300) {
scrollToTopBtn.classList.add('visible');
} else {
scrollToTopBtn.classList.remove('visible');
}
}
// Intersection Observer for animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate');
}
});
}, observerOptions);
// Observe elements for animation
const animateElements = document.querySelectorAll('.topic-card, .format-card, .audience-list li');
animateElements.forEach(el => {
observer.observe(el);
});
// Staggered animation for topic cards
const topicCards = document.querySelectorAll('.topic-card');
topicCards.forEach((card, index) => {
card.style.transitionDelay = `${index * 0.1}s`;
});
// Staggered animation for audience list items
const audienceItems = document.querySelectorAll('.audience-list li');
audienceItems.forEach((item, index) => {
item.style.transitionDelay = `${index * 0.1}s`;
});
// Staggered animation for format cards
const formatCards = document.querySelectorAll('.format-card');
formatCards.forEach((card, index) => {
card.style.transitionDelay = `${index * 0.2}s`;
});
// Event listeners
window.addEventListener('scroll', function() {
updateActiveNav();
toggleScrollToTop();
});
// Initial calls
updateActiveNav();
toggleScrollToTop();
// Add loading animation
document.body.style.opacity = '0';
document.body.style.transition = 'opacity 0.5s ease-in-out';
window.addEventListener('load', function() {
document.body.style.opacity = '1';
});
// Add hover effects for cards
const cards = document.querySelectorAll('.content-card, .topic-card, .format-card');
cards.forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-8px)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
});
});
// Add click effects for navigation
navLinks.forEach(link => {
link.addEventListener('click', function() {
this.style.transform = 'scale(0.95)';
setTimeout(() => {
this.style.transform = 'scale(1)';
}, 150);
});
});
// Keyboard navigation support
document.addEventListener('keydown', function(e) {
if (e.key === 'Home') {
e.preventDefault();
window.scrollTo({ top: 0, behavior: 'smooth' });
} else if (e.key === 'End') {
e.preventDefault();
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
}
});
// Add focus management for accessibility
const focusableElements = document.querySelectorAll('a, button, [tabindex]:not([tabindex="-1"])');
focusableElements.forEach(element => {
element.addEventListener('focus', function() {
this.style.outline = '2px solid #1e3a8a';
this.style.outlineOffset = '2px';
});
element.addEventListener('blur', function() {
this.style.outline = 'none';
});
});
});
// Add performance optimization
if ('requestIdleCallback' in window) {
requestIdleCallback(function() {
// Preload critical resources
const criticalImages = document.querySelectorAll('img[data-src]');
criticalImages.forEach(img => {
img.src = img.dataset.src;
});
});
}
// Add error handling
window.addEventListener('error', function(e) {
console.error('An error occurred:', e.error);
});
// Add resize handler for responsive adjustments
let resizeTimer;
window.addEventListener('resize', function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
// Recalculate positions after resize
updateActiveNav();
}, 250);
});
// Speaker Modal Logic + Dynamic Loading of Speakers via speakers.js
(function() {
let speakers = window.speakers || [];
const modal = document.getElementById('speaker-modal');
const modalName = document.getElementById('modal-speaker-name');
const modalCV = document.getElementById('modal-speaker-cv');
const closeBtn = document.querySelector('.speaker-modal-close');
const grid = document.querySelector('.speakers-grid');
const filterButtons = document.querySelectorAll('.filter-btn');
function createSpeakerCard(speaker, idx) {
const card = document.createElement('div');
card.className = 'speaker-card';
// Store the whole raw topic string for substring search
card.setAttribute('data-topic', (speaker.topic || ''));
card.innerHTML = `
<button class="speaker-photo-btn" data-speaker="${idx + 1}" aria-label="View CV">
<img src="${speaker.photo}" alt="Speaker Photo" class="speaker-photo" onerror="this.onerror=null;this.src='biophotos/placeholder.png'" />
</button>
<div class="speaker-info">
<h3 class="speaker-name">${speaker.name}</h3>
<p class="speaker-capacity">${speaker.capacity}</p>
${speaker.role ? `<p class="speaker-role"><em>${speaker.role}</em></p>` : ''}
<p class="speaker-topic">${speaker.topic}</p>
</div>
`;
return card;
}
function populateSpeakersGrid(speakers) {
if (!grid) return;
grid.innerHTML = '';
if (!speakers || speakers.length === 0) {
grid.innerHTML = '<p>No speaker data found.</p>';
return;
}
speakers.forEach((spk, idx) => {
grid.appendChild(createSpeakerCard(spk, idx));
});
}
function filterSpeakers(filter) {
const speakerCards = document.querySelectorAll('.speaker-card');
const filterNorm = filter.trim().toLowerCase();
speakerCards.forEach(card => {
const rawTopic = (card.getAttribute('data-topic') || '').toLowerCase();
if (filterNorm === 'all' || rawTopic.includes(filterNorm)) {
card.style.display = 'flex';
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
setTimeout(() => {
card.style.opacity = '1';
card.style.transform = 'translateY(0)';
}, 50);
} else {
card.style.display = 'none';
}
});
}
// Initialize speakers
populateSpeakersGrid(speakers);
// Add filter button event listeners
filterButtons.forEach(btn => {
btn.addEventListener('click', function() {
// Remove active class from all buttons
filterButtons.forEach(b => b.classList.remove('active'));
// Add active class to clicked button
this.classList.add('active');
// Filter speakers
const filter = this.getAttribute('data-filter');
filterSpeakers(filter);
});
});
// Open modal on photo click
document.addEventListener('click', function(e) {
const btn = e.target.closest('.speaker-photo-btn');
if (btn && grid.contains(btn)) {
const idx = parseInt(btn.getAttribute('data-speaker'), 10) - 1;
if (speakers[idx]) {
modalName.textContent = speakers[idx].name;
modalCV.textContent = speakers[idx].cv;
} else {
modalName.textContent = 'Speaker';
modalCV.textContent = 'CV not available.';
}
modal.style.display = 'flex';
modal.setAttribute('aria-hidden', 'false');
modal.focus();
document.body.style.overflow = 'hidden';
}
});
// Close modal on close button or background click
function closeModal() {
modal.style.display = 'none';
modal.setAttribute('aria-hidden', 'true');
document.body.style.overflow = '';
}
closeBtn && closeBtn.addEventListener('click', closeModal);
modal && modal.addEventListener('click', function(e) {
if (e.target === modal) closeModal();
});
// Close modal on Escape key
document.addEventListener('keydown', function(e) {
if (modal.style.display === 'flex' && (e.key === 'Escape' || e.key === 'Esc')) {
closeModal();
}
});
})();
// Programme Outline Logic
(function() {
const programme = window.programme || [];
const grid = document.querySelector('.programme-grid');
if (!grid) return;
grid.innerHTML = '';
if (!programme.length) return;
programme.forEach(day => {
const card = document.createElement('div');
card.className = 'format-card';
card.innerHTML = `
<h3>${day.date}</h3>
${day.sessions.map(sess =>
`<p><strong>${sess.time}</strong> ${sess.title}${sess.details ? `<br><span>${sess.details}</span>` : ''}</p>`).join('')}
`;
grid.appendChild(card);
});
})();
// Organizer info modal logic
(function() {
const orgs = {
kios: {
title: 'KIOS Research and Innovation Center of Excellence',
desc: 'The KIOS Research and Innovation Center of Excellence (KIOS CoE) operates within the University of Cyprus and currently is a leading research and innovation center in Cyprus and the region on Information and Communication Technologies (ICT). The Center collaborates strategically with Imperial College, London, as well as with a plethora of local and international research organizations and other stakeholders. Currently, the Center employs more than 200 people and is involved in more than 50 research and innovation projects funded by various European and national funding agencies, as well as in more than 25 projects funded by the industry.',
link: 'https://www.kios.ucy.ac.cy/'
},
cyprusacademy: {
title: 'Cyprus Academy of Sciences, Letters and Arts',
desc: 'The Cyprus Academy of Sciences, Letters and Arts was founded in 2017 and launched by the President of Cyprus Nicos Anastasiades in 2018. Its aim is to enhance the scientific and cultural achievements of Cyprus by promoting and rewarding excellence in Science, Letters, and Arts, and cultivating interactions between the Sciences, Letters, Humanities, and the Arts in the Republic of Cyprus. It is an independent and autonomous institution consisting of 3 Sections: Natural Sciences, Letters, and Arts (Humanities), and Ethical Sciences, Economic and Political Sciences.',
link: 'https://www.academyofcyprus.cy/'
}
};
const orgModal = document.getElementById('org-modal');
const orgTitle = document.getElementById('org-modal-title');
const orgDesc = document.getElementById('org-modal-desc');
const orgLink = document.getElementById('org-modal-link');
const orgClose = document.querySelector('.org-modal-close');
const logoItems = document.querySelectorAll('.logo-item');
function showOrgModal(orgKey) {
if (!orgs[orgKey]) return;
orgTitle.textContent = orgs[orgKey].title;
orgDesc.textContent = orgs[orgKey].desc;
orgLink.textContent = 'Visit Website';
orgLink.href = orgs[orgKey].link;
orgModal.style.display = 'flex';
orgModal.setAttribute('aria-hidden', 'false');
orgModal.focus();
document.body.style.overflow = 'hidden';
}
function closeOrgModal() {
orgModal.style.display = 'none';
orgModal.setAttribute('aria-hidden', 'true');
document.body.style.overflow = '';
}
logoItems.forEach(item => {
item.style.cursor = 'pointer';
item.addEventListener('click', function() {
const orgKey = this.getAttribute('data-org');
showOrgModal(orgKey);
});
});
orgClose && orgClose.addEventListener('click', closeOrgModal);
orgModal && orgModal.addEventListener('click', function(e) {
if (e.target === orgModal) closeOrgModal();
});
document.addEventListener('keydown', function(e) {
if (orgModal.style.display === 'flex' && (e.key === 'Escape' || e.key === 'Esc')) {
closeOrgModal();
}
});
})();