forked from RayeRen/acad-homepage.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
724 lines (594 loc) · 22.9 KB
/
Copy pathscript.js
File metadata and controls
724 lines (594 loc) · 22.9 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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
document.addEventListener('DOMContentLoaded', function() {
const currentYear = document.getElementById('current-year');
if (currentYear) {
currentYear.textContent = new Date().getFullYear();
}
setupMobileMenu();
setupSmoothScroll();
setupNavHighlight();
makeAllLinksOpenInNewTab();
setupLinkObserver();
loadNews();
loadHonors();
loadPublications();
});
function setupMobileMenu() {
const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
const mobileMenu = document.getElementById('mobile-menu');
if (!mobileMenuBtn || !mobileMenu) {
return;
}
mobileMenuBtn.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
});
mobileMenu.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
mobileMenu.classList.add('hidden');
});
});
}
function setupSmoothScroll() {
const navLinks = document.querySelectorAll('.nav-links a, .mobile-menu a');
navLinks.forEach(link => {
link.addEventListener('click', function(event) {
const href = this.getAttribute('href');
if (!href || !href.startsWith('#')) {
return;
}
const target = document.querySelector(href);
if (!target) {
return;
}
event.preventDefault();
const nav = document.querySelector('.top-nav');
const navHeight = nav ? nav.offsetHeight : 0;
const top = target.offsetTop - navHeight - 20;
window.scrollTo({
top,
behavior: 'smooth'
});
});
});
}
function setupNavHighlight() {
const navLinks = document.querySelectorAll('.nav-links a');
const sections = document.querySelectorAll('section[id]');
const nav = document.querySelector('.top-nav');
if (!navLinks.length || !sections.length || !nav) {
return;
}
window.addEventListener('scroll', () => {
let current = '';
const navHeight = nav.offsetHeight;
sections.forEach(section => {
if (window.pageYOffset >= section.offsetTop - navHeight - 100) {
current = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.classList.remove('active');
const target = (link.getAttribute('href') || '').replace('#', '');
if (target === current || (current === 'homepage' && target === 'about')) {
link.classList.add('active');
}
});
});
}
function loadNews() {
const homeContainer = document.getElementById('news-container');
const allContainer = document.getElementById('all-news-container');
if (!homeContainer && !allContainer) {
return;
}
fetch(getDataPath('news.json'))
.then(handleJsonResponse)
.then(items => {
if (homeContainer) {
renderNewsItems(items.slice(0, 8), homeContainer);
}
if (allContainer) {
renderNewsItems(items, allContainer);
}
})
.catch(error => {
console.error('Error loading news data:', error);
});
}
function loadHonors() {
const homeContainer = document.getElementById('honors-container');
const allContainer = document.getElementById('all-honors-container');
if (!homeContainer && !allContainer) {
return;
}
fetch(getDataPath('honors.json'))
.then(handleJsonResponse)
.then(items => {
if (homeContainer) {
renderHonorsItems(items.slice(0, 8), homeContainer);
}
if (allContainer) {
renderHonorsItems(items, allContainer);
}
})
.catch(error => {
console.error('Error loading honors data:', error);
});
}
function loadPublications() {
const featuredContainer = document.getElementById('featured-publications-container');
const preprintContainer = document.getElementById('featured-preprints-container');
const allContainer = document.getElementById('all-publications-container');
if (!featuredContainer && !preprintContainer && !allContainer) {
return;
}
fetch(getDataPath('publications.json'))
.then(handleJsonResponse)
.then(publications => {
if (featuredContainer) {
const accepted = publications
.filter(pub => String(pub.type || '').toLowerCase() === 'accepted')
.sort(compareAllPublications);
renderFeaturedPublications(featuredContainer, accepted);
}
if (preprintContainer) {
const preprints = publications
.filter(pub => String(pub.type || '').toLowerCase() !== 'accepted')
.sort(compareAllPublications);
renderFeaturedPublications(preprintContainer, preprints);
}
if (allContainer) {
renderAllPublicationsPage(allContainer, publications);
}
})
.catch(error => {
console.error('Error loading publications data:', error);
const container = featuredContainer || preprintContainer || allContainer;
if (container) {
container.innerHTML = '<p>Failed to load publications.</p>';
}
});
}
function renderFeaturedPublications(container, publications) {
container.innerHTML = '';
if (!publications.length) {
container.innerHTML = '<p>No featured publications available.</p>';
return;
}
const list = document.createElement('ul');
list.className = 'pub-list-ul';
publications.forEach(pub => {
list.appendChild(createPublicationItem(pub));
});
container.appendChild(list);
}
function renderAllPublicationsPage(container, publications) {
const filter = getPublicationFilter();
const filterIndicator = document.getElementById('filter-indicator');
let filtered = publications.slice();
if (filter === 'first-author') {
filtered = filtered.filter(pub => pub.isFirstAuthor === true);
if (filterIndicator) {
filterIndicator.textContent = '(First Author)';
}
} else if (filter === 'accepted') {
filtered = filtered.filter(pub => String(pub.type || '').toLowerCase() === 'accepted');
if (filterIndicator) {
filterIndicator.textContent = '(Accepted)';
}
} else if (filter === 'preprint') {
filtered = filtered.filter(pub => String(pub.type || '').toLowerCase() !== 'accepted');
if (filterIndicator) {
filterIndicator.textContent = '(Preprints)';
}
} else if (filterIndicator) {
filterIndicator.textContent = '';
}
updateFilterButtons(filter);
renderAllPublications(container, filtered);
}
function renderAllPublications(container, publications) {
container.innerHTML = '';
if (!publications.length) {
container.innerHTML = '<p class="empty-state">No publications found for this filter.</p>';
return;
}
const grouped = new Map();
publications
.slice()
.sort(compareAllPublications)
.forEach(pub => {
const yearLabel = getYearLabel(pub);
if (!grouped.has(yearLabel)) {
grouped.set(yearLabel, []);
}
grouped.get(yearLabel).push(pub);
});
Array.from(grouped.entries()).forEach(([year, items]) => {
const group = document.createElement('div');
group.className = 'pub-year-group';
const header = document.createElement('h3');
header.className = 'pub-year-header';
header.textContent = year;
group.appendChild(header);
const list = document.createElement('ul');
list.className = 'pub-list-ul';
items.forEach(pub => {
list.appendChild(createPublicationItem(pub));
});
group.appendChild(list);
container.appendChild(group);
});
}
function createPublicationItem(pub) {
const item = document.createElement('li');
item.className = 'pub-list-item with-thumbnail-expanded';
const content = document.createElement('div');
content.className = 'pub-content-wrapper';
const line1 = document.createElement('div');
line1.className = 'pub-line-1';
const title = document.createElement('span');
title.className = 'pub-title-text';
title.textContent = pub.displayTitle || pub.title || 'Untitled Publication';
line1.appendChild(title);
content.appendChild(line1);
const line2 = document.createElement('div');
line2.className = 'pub-line-2';
line2.innerHTML = pub.authors || '';
content.appendChild(line2);
const line3 = document.createElement('div');
line3.className = 'pub-line-3';
const venueFullName = getVenueFullName(pub.venue, pub.year);
const venueShortName = getVenueShortName(pub.venue, pub.year);
const venueText = venueFullName || pub.venue || 'Preprint';
const venueNameSpan = document.createElement('span');
venueNameSpan.textContent = venueText;
line3.appendChild(venueNameSpan);
if (shouldShowVenueTag(pub.venue, venueFullName, venueShortName)) {
const venueTag = document.createElement('span');
venueTag.className = 'pub-venue-tag pub-venue-inline-tag';
venueTag.textContent = venueShortName;
const lowerVenue = venueShortName.toLowerCase();
if (lowerVenue.includes('under review') || lowerVenue.includes('preprint') || lowerVenue.includes('arxiv')) {
venueTag.classList.add('tag-under-review');
} else {
venueTag.classList.add('tag-conference');
}
line3.appendChild(venueTag);
}
const badgeText = getHighlightBadge(pub.highlight);
if (badgeText) {
const badge = document.createElement('span');
badge.className = 'pub-badge-highlight';
badge.textContent = badgeText;
line3.appendChild(badge);
}
content.appendChild(line3);
if (pub.tags && Array.isArray(pub.tags)) {
const line4 = document.createElement('div');
line4.className = 'pub-line-4';
pub.tags.forEach(tag => {
const label = tag.text === 'Paper' ? 'PDF' : (tag.text || 'Link');
const usableLink = hasUsableLink(tag.link);
const button = document.createElement(usableLink ? 'a' : 'span');
button.className = 'pub-link-btn';
button.textContent = label;
if (usableLink) {
button.href = normalizeAssetPath(tag.link);
button.target = '_blank';
button.rel = 'noopener noreferrer';
} else {
button.classList.add('is-placeholder');
button.title = 'Replace "#" with a real link in data/publications.json';
}
line4.appendChild(button);
});
if (line4.children.length > 0) {
content.appendChild(line4);
}
}
item.appendChild(content);
if (pub.thumbnail) {
const thumbBox = document.createElement('div');
thumbBox.className = 'pub-thumbnail-box';
const thumbImg = document.createElement('img');
const preferredThumbnail = getPreferredThumbnail(pub.thumbnail);
thumbImg.src = preferredThumbnail.primary;
thumbImg.alt = `${pub.title || 'Publication'} preview`;
thumbImg.loading = 'lazy';
thumbImg.onerror = function() {
if (this.src !== preferredThumbnail.fallback) {
this.onerror = null;
this.src = preferredThumbnail.fallback;
}
};
thumbBox.appendChild(thumbImg);
item.appendChild(thumbBox);
}
return item;
}
function renderNewsItems(newsData, container) {
container.innerHTML = '';
newsData.forEach(newsItem => {
const newsElement = document.createElement('div');
newsElement.className = 'news-item';
const dateElement = document.createElement('span');
dateElement.className = 'news-date';
dateElement.textContent = newsItem.date || '';
const contentElement = document.createElement('div');
contentElement.className = 'news-content';
const textSpan = document.createElement('span');
textSpan.innerHTML = '🎉 ' + (newsItem.content || '');
contentElement.appendChild(textSpan);
if (Array.isArray(newsItem.links)) {
newsItem.links.forEach(link => {
const space = document.createTextNode(' ');
contentElement.appendChild(space);
const anchor = document.createElement('a');
anchor.href = normalizeAssetPath(link.url || '#');
anchor.textContent = link.text || 'Link';
if (shouldOpenInNewTab(anchor.getAttribute('href'))) {
anchor.target = '_blank';
anchor.rel = 'noopener noreferrer';
}
contentElement.appendChild(anchor);
});
}
newsElement.appendChild(dateElement);
newsElement.appendChild(contentElement);
container.appendChild(newsElement);
});
}
function renderHonorsItems(honorsData, container) {
container.innerHTML = '';
honorsData.forEach(honorItem => {
const honorElement = document.createElement('div');
honorElement.className = 'honor-item';
const yearElement = document.createElement('div');
yearElement.className = 'honor-year';
yearElement.textContent = honorItem.date || '';
const contentElement = document.createElement('div');
contentElement.className = 'honor-content';
const titleElement = document.createElement('h3');
titleElement.textContent = honorItem.title || '';
contentElement.appendChild(titleElement);
const descElement = document.createElement('p');
if (honorItem.description) {
descElement.innerHTML = honorItem.description;
} else {
descElement.textContent = honorItem.org || '';
}
contentElement.appendChild(descElement);
honorElement.appendChild(yearElement);
honorElement.appendChild(contentElement);
container.appendChild(honorElement);
});
}
function compareFeaturedPublications(a, b) {
const orderA = a.featuredOrder ?? Number.MAX_SAFE_INTEGER;
const orderB = b.featuredOrder ?? Number.MAX_SAFE_INTEGER;
if (orderA !== orderB) {
return orderA - orderB;
}
return compareAllPublications(a, b);
}
function compareAllPublications(a, b) {
const yearA = getComparableYear(a);
const yearB = getComparableYear(b);
if (yearA !== yearB) {
return yearB - yearA;
}
const acceptedA = String(a.type || '').toLowerCase() === 'accepted' ? 1 : 0;
const acceptedB = String(b.type || '').toLowerCase() === 'accepted' ? 1 : 0;
if (acceptedA !== acceptedB) {
return acceptedB - acceptedA;
}
const orderA = a.featuredOrder ?? Number.MAX_SAFE_INTEGER;
const orderB = b.featuredOrder ?? Number.MAX_SAFE_INTEGER;
if (orderA !== orderB) {
return orderA - orderB;
}
return String(a.title || '').localeCompare(String(b.title || ''));
}
function getComparableYear(pub) {
const parsedYear = parseInt(pub.year, 10);
if (!Number.isNaN(parsedYear)) {
return parsedYear;
}
return String(pub.type || '').toLowerCase() === 'accepted' ? 0 : 9999;
}
function getYearLabel(pub) {
const parsedYear = parseInt(pub.year, 10);
if (!Number.isNaN(parsedYear)) {
return String(parsedYear);
}
return 'Preprints / Under Review';
}
function getPublicationFilter() {
const params = new URLSearchParams(window.location.search);
return params.get('filter') || 'all';
}
function updateFilterButtons(filter) {
document.querySelectorAll('.filter-link').forEach(link => {
link.classList.remove('active');
});
let activeId = 'filter-all';
if (filter === 'first-author') {
activeId = 'filter-first';
} else if (filter === 'accepted') {
activeId = 'filter-accepted';
} else if (filter === 'preprint') {
activeId = 'filter-preprint';
}
const element = document.getElementById(activeId);
if (element) {
element.classList.add('active');
}
}
function getHighlightBadge(highlightText) {
const text = String(highlightText || '').toLowerCase();
if (text.includes('oral')) {
return 'Oral';
}
if (text.includes('spotlight')) {
return 'Spotlight';
}
return '';
}
function getPreferredThumbnail(thumbnailPath) {
const lastSlash = thumbnailPath.lastIndexOf('/');
if (lastSlash === -1) {
const normalized = normalizeAssetPath(thumbnailPath);
return { primary: normalized, fallback: normalized };
}
const directory = thumbnailPath.substring(0, lastSlash);
return {
primary: normalizeAssetPath(`${directory}/demo.gif`),
fallback: normalizeAssetPath(thumbnailPath)
};
}
function getVenueShortName(venueStr, year) {
if (!venueStr) {
return 'Preprint';
}
let revisionSuffix = '';
if (venueStr.toLowerCase().includes('major revision')) {
revisionSuffix = ', Major';
} else if (venueStr.toLowerCase().includes('minor revision')) {
revisionSuffix = ', Minor';
}
let s = venueStr.replace(/\d{4}/g, '').trim();
let suffix = '';
const conferences = ['NeurIPS', 'ICML', 'ICLR', 'EMNLP', 'ACL', 'CVPR', 'ICCV', 'ECCV', 'ICRA', 'AAAI', 'GLOBECOM', 'INFOCOM', 'MOBICOM'];
for (const conf of conferences) {
if (s.includes(conf)) {
if (year) {
const yearStr = String(year);
if (yearStr.length === 4) {
suffix = "'" + yearStr.substring(2);
}
}
return conf + suffix + revisionSuffix;
}
}
if (s.toLowerCase().includes('arxiv')) {
return 'ArXiv' + revisionSuffix;
}
if (s.includes('TMLR')) return 'TMLR' + revisionSuffix;
if (s.includes('TDSC')) return 'IEEE TDSC' + revisionSuffix;
if (s.includes('TMC')) return 'IEEE TMC' + revisionSuffix;
if (s.includes('JSAC')) return 'IEEE JSAC' + revisionSuffix;
if (s.includes('TGCN')) return 'IEEE TGCN' + revisionSuffix;
if (s.includes('LNET')) return 'IEEE LNET' + revisionSuffix;
if (s.includes('TNSE')) return 'IEEE TNSE' + revisionSuffix;
if (s.includes('IOTJ') || s.includes('IoTJ')) return 'IEEE IoTJ' + revisionSuffix;
return s || 'Preprint';
}
function getVenueFullName(venueStr) {
if (!venueStr) {
return '';
}
const s = venueStr.replace(/\d{4}/g, '').trim();
if (s.includes('TDSC')) return 'IEEE Transactions on Dependable and Secure Computing';
if (s.includes('TMC')) return 'IEEE Transactions on Mobile Computing';
if (s.includes('JSAC')) return 'IEEE Journal on Selected Areas in Communications';
if (s.includes('TGCN')) return 'IEEE Transactions on Green Communications and Networking';
if (s.includes('TNSE')) return 'IEEE Transactions on Network Science and Engineering';
if (s.includes('IoTJ') || s.includes('IOTJ')) return 'IEEE Internet of Things Journal';
if (s.includes('LNET') || s.includes('LNet')) return 'IEEE Networking Letters';
if (s.includes('NeurIPS')) return 'Annual Conference on Neural Information Processing Systems';
if (s.includes('ICML')) return 'International Conference on Machine Learning';
if (s.includes('CVPR')) return 'IEEE/CVF Conference on Computer Vision and Pattern Recognition';
if (s.includes('ICCV')) return 'IEEE/CVF International Conference on Computer Vision';
if (s.includes('ECCV')) return 'European Conference on Computer Vision';
if (s.includes('ICRA')) return 'IEEE International Conference on Robotics and Automation';
if (s.includes('AAAI')) return 'AAAI Conference on Artificial Intelligence';
if (s.includes('GLOBECOM')) return 'IEEE Global Communications Conference';
if (s.includes('INFOCOM')) return 'IEEE International Conference on Computer Communications';
if (s.includes('MOBICOM')) return 'Annual International Conference on Mobile Computing and Networking';
if (s.includes('ICLR')) return 'International Conference on Learning Representations';
if (s.includes('EMNLP')) return 'Conference on Empirical Methods in Natural Language Processing';
if (s.includes('ACL')) return 'Annual Meeting of the Association for Computational Linguistics';
if (s.includes('TMLR')) return 'Transactions on Machine Learning Research';
if (s.toLowerCase().includes('arxiv')) return 'arXiv preprint';
return s;
}
function shouldShowVenueTag(venueStr, fullVenueName, venueShort) {
if (!venueShort) {
return false;
}
const shortLower = venueShort.toLowerCase().trim();
const fullLower = String(fullVenueName || '').toLowerCase().trim();
if (!fullLower || shortLower === fullLower) {
return false;
}
if (venueStr && venueStr.toLowerCase().includes('under review')) {
return false;
}
return true;
}
function getDataPath(fileName) {
const base = window.location.pathname.includes('/pages/') ? `../data/${fileName}` : `data/${fileName}`;
return `${base}?t=${Date.now()}`;
}
function normalizeAssetPath(path) {
if (!path) {
return path;
}
if (/^(https?:|mailto:|tel:|#)/i.test(path)) {
return path;
}
if (window.location.pathname.includes('/pages/') && !path.startsWith('../')) {
return `../${path}`;
}
return path;
}
function hasUsableLink(path) {
return Boolean(path) && path !== '#';
}
function handleJsonResponse(response) {
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
return response.json();
}
function makeAllLinksOpenInNewTab() {
document.querySelectorAll('a').forEach(link => {
const href = link.getAttribute('href');
if (shouldOpenInNewTab(href)) {
link.target = '_blank';
link.rel = 'noopener noreferrer';
}
});
}
function shouldOpenInNewTab(href) {
if (!href) {
return false;
}
// Only external (absolute) URLs open in a new tab; all relative/in-page
// links (including filtered .html?query links) stay in the same tab.
if (/^(https?:)?\/\//i.test(href)) {
return true;
}
return false;
}
function setupLinkObserver() {
if (!document.body) {
return;
}
const observer = new MutationObserver(mutations => {
let shouldRefreshLinks = false;
for (const mutation of mutations) {
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
shouldRefreshLinks = true;
break;
}
}
if (shouldRefreshLinks) {
makeAllLinksOpenInNewTab();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}