-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
59 lines (47 loc) · 1.84 KB
/
script.js
File metadata and controls
59 lines (47 loc) · 1.84 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
document.addEventListener("DOMContentLoaded", () => {
fetch('schedule.json')
.then(response => response.json())
.then(data => buildScheduleTable(data))
.catch(err => console.error(err));
});
function buildScheduleTable(data) {
const table = document.getElementById("schedule-table");
const tbody = table.querySelector('tbody');
const colLabels = ["Date", "Speakers", "Topic"];
data.forEach(entry => {
const tr = document.createElement('tr');
// Date Cell
const dateTd = document.createElement('td');
dateTd.setAttribute('data-label', colLabels[0]);
dateTd.textContent = entry.date || 'TBA';
tr.appendChild(dateTd);
// Speakers Cell
const speakerTd = document.createElement('td');
speakerTd.setAttribute('data-label', colLabels[1]);
let speakerContent = '';
if (Array.isArray(entry.speakers) && entry.speakers.length > 0) {
const speakerNames = entry.speakers.map(sp => {
return (sp.link && sp.link.trim() !== '')
? `<a href="${sp.link}" target="_blank" rel="noopener noreferrer">${sp.name}</a>`
: sp.name;
});
speakerContent = speakerNames.join('; ');
} else if (entry.speaker && entry.speaker.trim() !== '') {
speakerContent = entry.speaker;
} else {
speakerContent = 'TBA';
}
speakerTd.innerHTML = speakerContent;
tr.appendChild(speakerTd);
// Topic Cell
const topicTd = document.createElement('td');
topicTd.setAttribute('data-label', colLabels[2]);
let topicText = (entry.topic && entry.topic.trim() !== '') ? entry.topic : 'TBA';
if (entry.topicSlides && entry.topicSlides.trim() !== '') {
topicText = `<a href="${entry.topicSlides}" target="_blank" rel="noopener noreferrer">${topicText}</a>`;
}
topicTd.innerHTML = topicText;
tr.appendChild(topicTd);
tbody.appendChild(tr);
});
}