-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimeline.js
69 lines (62 loc) · 2.13 KB
/
timeline.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
//define events data
const events = [
{
year: '2023',
events: [
{
title: 'MEG frequency-tagging reveals a grid-like code during attentional movements',
authors: 'G. Giari, L. Vignali, Y. Xu, R. Bottini',
journal: 'Cell Reports',
link: 'https://www.sciencedirect.com/science/article/pii/S2211124723012214',
code: 'https://github.com/giulianogiari/GridFT'
},
]
},
{
'year': '2020',
events: [
{
title: 'Spatiotemporal properties of the neural representation of conceptual content for words and pictures-an MEG study',
authors: 'G. Giari, E. Leonardelli, Y. Tao, M. Machado, S. L. Fairhall',
journal: 'NeuroImage',
link: 'https://www.sciencedirect.com/science/article/pii/S1053811920303992'
},
]
}
];
// Create a function that returns HTML for a single year
function createEventHTML(yearData) {
let yearHTML = `<div class="year" id="${yearData.year}"><h2>${yearData.year}</h2></div>`;
yearData.events.forEach(event => {
yearHTML += `
<div class="event">
<div class="details">
<h3><a href="${event.link}">${event.title}</a></h3>
<p>${event.authors}</p>
<p>${event.journal}</p>
`;
// add code only if present
if (event.code) {
yearHTML += `<a href=${event.code}>Code </a>`;
}
yearHTML += `
</div>
</div>
`;
});
return yearHTML;
}
// Create a function that returns HTML for a single year
function createSidebarLink(year) {
return `<a href="#${year}">${year}</a>`;
}
// Select the timeline container in the publications.html page
const timeline = document.querySelector('.timeline');
// Loop through your events array and create HTML for each event
events.forEach(yearData => {
timeline.innerHTML += createEventHTML(yearData);
});
const sidebar = document.querySelector('.sidebar');
events.forEach(yearData => {
sidebar.innerHTML += createSidebarLink(yearData.year);
});