Repository navigation
Expand file tree
/
Copy pathscripts.js
More file actions
171 lines (142 loc) · 5 KB
/
Copy pathscripts.js
File metadata and controls
171 lines (142 loc) · 5 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
// Global variables
let allPublications = [];
let showingSelected = true;
const LINK_LABELS = {
pdf: 'PDF',
arxiv: 'arXiv',
code: 'Code',
project: 'Project Page',
poster: 'Poster',
slides: 'Slides',
video: 'Video',
bibtex: 'BibTeX'
};
const HIGHLIGHT_AUTHOR = 'Yallup';
// Initialize the page
document.addEventListener('DOMContentLoaded', function() {
loadPublications();
const sections = document.querySelectorAll('section');
sections.forEach((section, index) => {
section.style.animationDelay = `${index * 0.1}s`;
});
const toggleButton = document.getElementById('toggle-publications');
if (toggleButton) {
toggleButton.addEventListener('click', togglePublications);
}
});
// Load publications from JSON file
function loadPublications() {
fetch('publications.json')
.then(response => {
if (!response.ok) {
throw new Error(`Network response was not ok: ${response.status}`);
}
return response.json();
})
.then(data => {
allPublications = data.publications;
renderPublications(true);
})
.catch(error => {
console.error('Error loading publications:', error);
const container = document.getElementById('publications-container');
container.innerHTML = `Error loading publications.`;
});
}
// Toggle between showing all or selected publications
function togglePublications() {
showingSelected = !showingSelected;
renderPublications(showingSelected);
const toggleButton = document.getElementById('toggle-publications');
toggleButton.textContent = showingSelected ? 'Extend' : 'Collapse';
const toggleHeader = document.getElementById('toggle-header');
toggleHeader.textContent = showingSelected ? 'Recent Publications' : 'Highlights';
}
// Render publications based on selection state
function renderPublications(selectedOnly) {
const publicationsContainer = document.getElementById('publications-container');
publicationsContainer.innerHTML = '';
const pubsToShow = selectedOnly ?
allPublications.filter(pub => pub.selected === 1) :
allPublications;
pubsToShow.forEach(publication => {
const pubElement = createPublicationElement(publication);
publicationsContainer.appendChild(pubElement);
});
const note = document.getElementById('pub-note');
if (note) note.style.display = selectedOnly ? 'none' : 'block';
}
// Create HTML element for a publication
function createPublicationElement(publication) {
const pubItem = document.createElement('div');
pubItem.className = 'publication-item';
if (publication.thumbnail) {
const thumbnail = document.createElement('div');
thumbnail.className = 'pub-thumbnail';
thumbnail.onclick = () => openModal(publication.thumbnail);
const thumbnailImg = document.createElement('img');
thumbnailImg.src = publication.thumbnail;
thumbnailImg.alt = `${publication.title} thumbnail`;
thumbnail.appendChild(thumbnailImg);
pubItem.appendChild(thumbnail);
}
const content = document.createElement('div');
content.className = 'pub-content';
const title = document.createElement('div');
title.className = 'pub-title';
title.textContent = publication.title;
content.appendChild(title);
const authors = document.createElement('div');
authors.className = 'pub-authors';
authors.innerHTML = publication.authors.map(author =>
author.includes(HIGHLIGHT_AUTHOR)
? `<span class="highlight-name">${author}</span>`
: author
).join(', ');
content.appendChild(authors);
const venueContainer = document.createElement('div');
venueContainer.className = 'pub-venue-container';
const venue = document.createElement('div');
venue.className = 'pub-venue';
venue.textContent = publication.venue;
venueContainer.appendChild(venue);
if (publication.award && publication.award.length > 0) {
const award = document.createElement('div');
award.className = 'pub-award';
award.textContent = publication.award;
venueContainer.appendChild(award);
}
content.appendChild(venueContainer);
if (publication.links) {
const links = document.createElement('div');
links.className = 'pub-links';
Object.entries(publication.links).forEach(([key, href]) => {
const a = document.createElement('a');
a.href = href;
a.textContent = `[${LINK_LABELS[key] || key}]`;
links.appendChild(a);
});
content.appendChild(links);
}
pubItem.appendChild(content);
return pubItem;
}
// Modal functionality for viewing original images
function openModal(imageSrc) {
const modal = document.getElementById('imageModal');
const modalImg = document.getElementById('modalImage');
modal.style.display = "block";
setTimeout(() => modal.classList.add('show'), 10);
modalImg.src = imageSrc;
}
function closeModal() {
const modal = document.getElementById('imageModal');
modal.classList.remove('show');
setTimeout(() => modal.style.display = "none", 300);
}
window.onclick = function(event) {
const modal = document.getElementById('imageModal');
if (event.target == modal) {
closeModal();
}
};