-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
203 lines (170 loc) · 6 KB
/
scripts.js
File metadata and controls
203 lines (170 loc) · 6 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
// Global variables
let allPublications = [];
let showingSelected = true;
// Initialize the page
document.addEventListener('DOMContentLoaded', function() {
// Load publications data
loadPublications();
// Initialize animation delays for sections
const sections = document.querySelectorAll('section');
sections.forEach((section, index) => {
section.style.animationDelay = `${index * 0.1}s`;
});
// Add event listener for toggle button
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 => {
console.log("Publications loaded successfully:", data);
allPublications = data.publications;
renderPublications(true);
})
.catch(error => {
console.error('Error loading publications:', error);
// Create fallback publications display if JSON loading fails
displayFallbackPublications();
});
}
// Fallback if JSON loading fails
function displayFallbackPublications() {
const container = document.getElementById('publications-container');
container.innerHTML = `Error loading publications.`;
}
// Toggle between showing all or selected publications
function togglePublications() {
showingSelected = !showingSelected;
renderPublications(showingSelected);
// Update button text
const toggleButton = document.getElementById('toggle-publications');
toggleButton.textContent = showingSelected ? 'Show All' : 'Show Selected';
const toggleHeader = document.getElementById('toggle-header');
toggleHeader.textContent = showingSelected ? 'Selected Publications' : 'All Publications';
}
// 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);
});
}
// Create HTML element for a publication
function createPublicationElement(publication) {
const pubItem = document.createElement('div');
pubItem.className = 'publication-item';
// Create 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);
// Create content container
const content = document.createElement('div');
content.className = 'pub-content';
// Add title
const title = document.createElement('div');
title.className = 'pub-title';
title.textContent = publication.title;
content.appendChild(title);
// Add authors with highlight
const authors = document.createElement('div');
authors.className = 'pub-authors';
// Format authors with highlighting
let authorsHTML = '';
publication.authors.forEach((author, index) => {
if (author.includes('Sanghyun Byun')) {
authorsHTML += `<span class="highlight-name">${author}</span>`;
} else {
authorsHTML += author;
}
if (index < publication.authors.length - 1) {
authorsHTML += ', ';
}
});
authors.innerHTML = authorsHTML;
content.appendChild(authors);
// Add venue with award if present
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);
// Add award if it exists
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);
// Add links if they exist
if (publication.links) {
const links = document.createElement('div');
links.className = 'pub-links';
if (publication.links.pdf) {
const pdfLink = document.createElement('a');
pdfLink.href = publication.links.pdf;
pdfLink.textContent = '[PDF]';
links.appendChild(pdfLink);
}
if (publication.links.code) {
const codeLink = document.createElement('a');
codeLink.href = publication.links.code;
codeLink.textContent = '[Code]';
links.appendChild(codeLink);
}
if (publication.links.project) {
const projectLink = document.createElement('a');
projectLink.href = publication.links.project;
projectLink.textContent = '[Project Page]';
links.appendChild(projectLink);
}
content.appendChild(links);
}
// Assemble the publication item
pubItem.appendChild(thumbnail);
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);
}
// Close modal when clicking outside the image
window.onclick = function(event) {
const modal = document.getElementById('imageModal');
if (event.target == modal) {
closeModal();
}
}