-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
1741 lines (1449 loc) · 58.8 KB
/
script.js
File metadata and controls
1741 lines (1449 loc) · 58.8 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
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
document.addEventListener('DOMContentLoaded', () => {
initContent();
initSmoothScrolling();
initScrollSpy();
initScrollAnimations();
});
function initContent() {
const content = window.siteContent;
if (!content) {
return;
}
renderProfile(content.profile);
renderNavigation(content.navigation);
renderFooter(content.footerHTML);
const pageKey = document.body.dataset.page;
const pageContent = content.pages?.[pageKey];
if (!pageKey || !pageContent) {
return;
}
if (pageKey === 'index' && pageContent.biography) {
renderBiography(pageContent.biography);
// Render achievements on the home page
if (content.pages?.achievements) {
renderAchievements(content.pages.achievements);
}
}
if (pageKey === 'experience' && pageContent.timeline) {
renderTimeline('experience', pageContent.timeline);
}
if (pageKey === 'education' && pageContent.timeline) {
renderTimeline('education', pageContent.timeline);
}
if (pageKey === 'achievements') {
renderAchievements(pageContent);
}
if (pageKey === 'talks') {
renderTalks(pageContent);
}
if (pageKey === 'volunteer') {
renderVolunteer(pageContent);
}
if (pageKey === 'awards') {
renderAwards(pageContent);
}
if (pageKey === 'publications') {
renderPublications(pageContent);
}
if (pageKey === 'others') {
renderOthers(pageContent);
}
}
function renderProfile(profile) {
const container = document.getElementById('profile-section');
if (!container || !profile) {
return;
}
const socialLinksHTML = (profile.socialLinks || []).map(link => {
const isExternal = /^https?:\/\//.test(link.href) && !link.href.includes('hideaki-j.github.io');
const targetAttr = isExternal ? ' target="_blank" rel="noopener noreferrer"' : '';
return `<a href="${link.href}"${targetAttr} title="${link.title}"><i class="${link.icon}"></i></a>`;
}).join('');
const image = profile.image || {};
container.innerHTML = `
<div class="profile-image">
<img src="${image.src || ''}" alt="${image.alt || ''}" onerror="this.style.display='none'; this.nextElementSibling.style.display='flex';">
<div class="profile-placeholder">
<i class="${image.placeholderIcon || 'fas fa-user'}"></i>
</div>
</div>
<h1>${profile.name || ''}</h1>
<p class="tagline">${profile.tagline || ''}</p>
<div class="social-links">
${socialLinksHTML}
</div>
`;
}
function renderNavigation(navigation = []) {
const container = document.getElementById('sidebar-nav');
if (!container) {
return;
}
const currentPage = document.body.dataset.page;
container.innerHTML = navigation.map(link => {
const isActive = link.page === currentPage ? ' active' : '';
return `
<a href="${link.href}" class="nav-link${isActive}">
<i class="${link.icon}"></i> ${link.label}
</a>
`;
}).join('');
const schedule = typeof requestAnimationFrame === 'function'
? requestAnimationFrame
: (cb => setTimeout(cb, 0));
schedule(() => {
const activeLink = container.querySelector('.nav-link.active');
if (!activeLink) {
return;
}
if (typeof activeLink.scrollIntoView === 'function') {
activeLink.scrollIntoView({
behavior: 'auto',
block: 'nearest',
inline: 'center'
});
} else {
const containerWidth = container.clientWidth;
if (containerWidth <= 0) {
return;
}
const target =
activeLink.offsetLeft - (containerWidth - activeLink.offsetWidth) / 2;
const maxScroll = Math.max(0, container.scrollWidth - containerWidth);
container.scrollLeft = Math.max(0, Math.min(target, maxScroll));
}
});
}
function renderFooter(footerHTML) {
const footer = document.getElementById('footer-text');
if (footer && footerHTML) {
footer.innerHTML = footerHTML;
}
}
function renderBiography(biography) {
const container = document.getElementById('bio-card');
if (!container) {
return;
}
const paragraphs = (biography.paragraphsHTML || []).join('\n');
container.innerHTML = `
<h2>${biography.titleHTML || ''}</h2>
${paragraphs}
`;
}
function renderTimeline(prefix, timeline) {
const titleEl = document.getElementById(`${prefix}-title`);
const container = document.getElementById(`${prefix}-timeline`);
if (titleEl && timeline.titleHTML) {
titleEl.innerHTML = timeline.titleHTML;
}
if (!container) {
return;
}
const iconLibrary = window.siteIcons || {};
container.innerHTML = (timeline.items || []).map(item => {
const iconRef = item.iconKey || item.icon;
const iconConfig = typeof iconRef === 'string' ? iconLibrary[iconRef] : undefined;
let iconHTML = '';
if (iconConfig && iconConfig.src) {
const defaultScale = typeof iconConfig.scale === 'number' ? iconConfig.scale : 100;
const rawScale = typeof item.iconScale === 'number' ? item.iconScale : defaultScale;
const clampedScale = Math.max(0, Math.min(rawScale, 100));
const scaleRatio = clampedScale / 100;
const scaleAttr = scaleRatio !== 1 ? ` style="--icon-image-scale: ${scaleRatio};"` : '';
const altText = iconConfig.alt || item.heading || '';
iconHTML = `
<div class="timeline-icon-inner"${scaleAttr}>
<img src="${iconConfig.src}" alt="${altText}">
</div>
`;
} else if (typeof iconRef === 'string' && iconRef.includes('.')) {
const rawScale = typeof item.iconScale === 'number' ? item.iconScale : 100;
const clampedScale = Math.max(0, Math.min(rawScale, 100));
const scaleRatio = clampedScale / 100;
const scaleAttr = scaleRatio !== 1 ? ` style="--icon-image-scale: ${scaleRatio};"` : '';
const altText = item.heading || '';
iconHTML = `
<div class="timeline-icon-inner"${scaleAttr}>
<img src="${iconRef}" alt="${altText}">
</div>
`;
} else {
iconHTML = iconRef || '';
}
const dateNoteHTML = item.dateNote ? ` <span class="timeline-date-note">(${item.dateNote})</span>` : '';
return `
<div class="card timeline-card">
<div class="timeline-icon">${iconHTML}</div>
<h3>${item.heading || ''}</h3>
<p class="role">${item.role || ''}</p>
<p class="date">${item.date || ''}${dateNoteHTML}</p>
${item.bodyHTML || ''}
</div>
`;
}).join('');
}
function renderAchievements(achievements) {
const titleEl = document.getElementById('achievements-title');
const grid = document.getElementById('achievements-grid');
const ctaContainer = document.getElementById('achievements-cta');
if (titleEl && achievements.titleHTML) {
titleEl.innerHTML = achievements.titleHTML;
}
if (grid) {
grid.innerHTML = (achievements.cards || []).map(card => {
let numberHTML;
if (card.second_number) {
numberHTML = `<p class="achievement-number">${card.number || ''} <span class="number-divider">|</span> ${card.second_number}</p>`;
} else {
numberHTML = `<p class="achievement-number">${card.number || ''}</p>`;
}
const content = `
<div class="achievement-icon">
<i class="${card.iconClass || ''}"></i>
</div>
<h3>${card.title || ''}</h3>
${numberHTML}
<p class="achievement-desc">${card.descriptionHTML || ''}</p>
`;
if (card.href) {
const isExternal = (card.href.startsWith('http://') || card.href.startsWith('https://')) && !card.href.includes('hideaki-j.github.io');
const target = isExternal ? ' target="_blank" rel="noopener noreferrer"' : '';
return `<a href="${card.href}"${target} class="card achievement-card achievement-card-link">${content}</a>`;
} else {
return `<div class="card achievement-card">${content}</div>`;
}
}).join('');
}
if (ctaContainer && achievements.cta) {
const { href, iconClass, label } = achievements.cta;
ctaContainer.innerHTML = `
<a href="${href || '#'}" target="_blank" class="cta-button">
<i class="${iconClass || ''}"></i> ${label || ''}
</a>
`;
}
}
function renderTalks(talks) {
const titleEl = document.getElementById('talks-title');
const container = document.getElementById('talks-timeline');
if (titleEl && talks.titleHTML) {
titleEl.innerHTML = talks.titleHTML;
}
if (!container || !talks.timeline) {
return;
}
const visibleCap = 5;
const iconLibrary = window.siteIcons || {};
const timelineConfig = talks.timeline || {};
let highlightedSource = Array.isArray(timelineConfig.highlighted_talks)
? timelineConfig.highlighted_talks.slice()
: [];
let otherSource = Array.isArray(timelineConfig.other_talks)
? timelineConfig.other_talks.slice()
: [];
if (!highlightedSource.length && Array.isArray(timelineConfig.items)) {
const fallbackItems = timelineConfig.items.slice();
highlightedSource = fallbackItems.slice(0, visibleCap);
otherSource = fallbackItems.slice(visibleCap);
}
if (!highlightedSource.length && otherSource.length) {
highlightedSource = otherSource.slice(0, visibleCap);
otherSource = otherSource.slice(visibleCap);
}
const mapItems = (list, prefix, startOrder) => list.map((item, index) => ({
...item,
__index: index,
__order: startOrder + index,
__key: `${prefix}-${index}`
}));
const highlightedItems = mapItems(highlightedSource, 'highlighted', 0);
const otherItems = mapItems(otherSource, 'other', highlightedItems.length);
const allItems = highlightedItems.concat(otherItems);
if (!allItems.length) {
container.innerHTML = '';
return;
}
const buildTalkCard = (item, options = {}) => {
const { hidden = false, animate = false } = options;
const iconRef = item.iconKey || item.icon;
const iconConfig = typeof iconRef === 'string' ? iconLibrary[iconRef] : undefined;
let iconHTML = '';
const bodyHTML = item.bodyHTML || '';
const textHTML = `<p class="single-line-text">${bodyHTML}</p>`;
if (iconConfig && iconConfig.src) {
const defaultScale = typeof iconConfig.scale === 'number' ? iconConfig.scale : 100;
const rawScale = typeof item.iconScale === 'number' ? item.iconScale : defaultScale;
const clampedScale = Math.max(0, Math.min(rawScale, 100));
const scaleRatio = clampedScale / 100;
const scaleAttr = scaleRatio !== 1 ? ` style="--icon-image-scale: ${scaleRatio};"` : '';
const altText = iconConfig.alt || '';
iconHTML = `
<div class="timeline-icon">
<div class="timeline-icon-inner"${scaleAttr}>
<img src="${iconConfig.src}" alt="${altText}">
</div>
</div>
`;
}
const hiddenStyle = hidden ? ' style="display: none;"' : '';
const keyAttr = typeof item.__key === 'string' ? ` data-talk-key="${item.__key}"` : '';
if (iconHTML) {
const classes = ['card', 'timeline-card', 'single-line-card'];
if (animate) {
classes.push('talk-card-animate');
}
return `
<div class="${classes.join(' ')}"${keyAttr}${hiddenStyle}>
${iconHTML}
${textHTML}
</div>
`;
} else {
const classes = ['card', 'timeline-card', 'talk-item'];
if (animate) {
classes.push('talk-card-animate');
}
return `
<div class="${classes.join(' ')}"${keyAttr}${hiddenStyle}>
<p>${item.bodyHTML || ''}</p>
</div>
`;
}
};
if (!otherItems.length) {
container.innerHTML = allItems.map(item => buildTalkCard(item)).join('');
return;
}
const getTalkYear = item => {
const matches = (item.bodyHTML || '').match(/(\d{4})/g);
if (!matches || !matches.length) {
return -Infinity;
}
const year = parseInt(matches[matches.length - 1], 10);
return Number.isFinite(year) ? year : -Infinity;
};
const sortedItems = allItems.slice().sort((a, b) => {
const yearA = getTalkYear(a);
const yearB = getTalkYear(b);
if (yearA !== yearB) {
return yearB - yearA;
}
const orderA = typeof a.__order === 'number' ? a.__order : 0;
const orderB = typeof b.__order === 'number' ? b.__order : 0;
return orderA - orderB;
});
const buildControlRow = (state, hiddenCount, sortMode) => {
if (hiddenCount <= 0) {
return '';
}
const toggleLabel = state === 'collapsed'
? `Show more ${hiddenCount} ${formatTalkCount(hiddenCount)}`
: `Hide ${hiddenCount} ${formatTalkCount(hiddenCount)}`;
const sortLabel = sortMode === 'year' ? 'Original order' : 'Sort by year';
const sortButtonHTML = state === 'expanded'
? `<button type="button" class="scholar-toggle-button talks-sort-button" data-sort="${sortMode}">${sortLabel}</button>`
: '';
return `
<div class="scholar-toggle-row talks-toggle-row">
<button type="button" class="scholar-toggle-button talks-toggle-button" data-state="${state}">${toggleLabel}</button>
${sortButtonHTML}
</div>
`;
};
const viewState = {
display: 'collapsed',
sort: 'original',
transition: 'init'
};
const triggerTalkAnimation = shouldAnimate => {
if (!shouldAnimate) {
return;
}
const animatedCards = Array.from(container.querySelectorAll('.talk-card-animate'));
if (!animatedCards.length) {
return;
}
requestAnimationFrame(() => {
requestAnimationFrame(() => {
animatedCards.forEach(card => {
card.classList.add('talk-card-animate-active');
});
});
});
animatedCards.forEach(card => {
const handleTransitionEnd = () => {
card.classList.remove('talk-card-animate', 'talk-card-animate-active');
card.removeEventListener('transitionend', handleTransitionEnd);
};
card.addEventListener('transitionend', handleTransitionEnd);
});
};
const captureCardPositions = () => {
const positions = new Map();
if (!container) {
return positions;
}
const cards = container.querySelectorAll('[data-talk-key]');
cards.forEach(card => {
const key = card.getAttribute('data-talk-key');
if (!key) {
return;
}
if (card.offsetParent === null) {
return;
}
const rect = card.getBoundingClientRect();
positions.set(key, {
top: rect.top + window.scrollY,
left: rect.left + window.scrollX
});
});
return positions;
};
const animateSortMovement = preRects => {
if (!preRects || !preRects.size) {
return;
}
const cards = Array.from(container.querySelectorAll('[data-talk-key]')).filter(card => card.offsetParent !== null);
const movingCards = [];
cards.forEach(card => {
const key = card.getAttribute('data-talk-key');
if (!key || !preRects.has(key)) {
return;
}
const rect = card.getBoundingClientRect();
const currentTop = rect.top + window.scrollY;
const currentLeft = rect.left + window.scrollX;
const previous = preRects.get(key);
const deltaX = previous.left - currentLeft;
const deltaY = previous.top - currentTop;
if (Math.abs(deltaX) < 1 && Math.abs(deltaY) < 1) {
return;
}
card.style.transition = 'none';
card.style.transform = `translate(${deltaX}px, ${deltaY}px)`;
card.style.willChange = 'transform, opacity';
card.style.opacity = '0.9';
card.getBoundingClientRect();
movingCards.push(card);
});
if (!movingCards.length) {
return;
}
requestAnimationFrame(() => {
movingCards.forEach(card => {
const cleanup = event => {
if (event.propertyName !== 'transform') {
return;
}
card.style.transition = '';
card.style.transform = '';
card.style.willChange = '';
card.style.opacity = '';
card.removeEventListener('transitionend', cleanup);
};
card.addEventListener('transitionend', cleanup);
card.style.transition = 'transform 0.75s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.55s ease';
card.style.transform = 'translate(0, 0)';
card.style.opacity = '1';
});
});
};
const pinnedItems = highlightedItems.length
? highlightedItems
: allItems.slice(0, Math.min(visibleCap, allItems.length));
const pinnedKeySet = new Set(pinnedItems.map(item => item.__key));
const totalHiddenCount = Math.max(allItems.length - pinnedItems.length, 0);
const renderState = () => {
const transitionType = viewState.transition || 'none';
const preRects = transitionType === 'sort' ? captureCardPositions() : null;
viewState.transition = null;
const isSortedByYear = viewState.sort === 'year';
const sourceItems = isSortedByYear ? sortedItems : allItems;
const animateTargets = new Set();
let visibleItems;
let hiddenItems = [];
if (viewState.display === 'expanded') {
if (isSortedByYear) {
visibleItems = sourceItems;
} else {
const remainder = sourceItems.filter(item => !pinnedKeySet.has(item.__key));
if (transitionType === 'expand') {
remainder.forEach(item => animateTargets.add(item.__key));
}
visibleItems = pinnedItems.concat(remainder);
}
} else {
visibleItems = pinnedItems;
hiddenItems = allItems.filter(item => !pinnedKeySet.has(item.__key));
}
let html = visibleItems.map(item => buildTalkCard(item, {
animate: animateTargets.has(item.__key)
})).join('');
if (hiddenItems.length) {
html += hiddenItems.map(item => buildTalkCard(item, { hidden: true })).join('');
}
html += buildControlRow(viewState.display, totalHiddenCount, viewState.sort);
container.innerHTML = html;
attachControlHandlers();
if (transitionType === 'sort') {
animateSortMovement(preRects);
} else {
triggerTalkAnimation(animateTargets.size > 0);
}
};
const attachControlHandlers = () => {
const toggleButton = container.querySelector('.talks-toggle-button');
if (toggleButton) {
toggleButton.addEventListener('click', () => {
const nextState = toggleButton.dataset.state === 'collapsed' ? 'expanded' : 'collapsed';
if (nextState === 'collapsed') {
viewState.sort = 'original';
}
viewState.transition = nextState === 'expanded' ? 'expand' : 'collapse';
viewState.display = nextState;
renderState();
});
}
const sortButton = container.querySelector('.talks-sort-button');
if (sortButton) {
sortButton.addEventListener('click', () => {
viewState.transition = 'sort';
viewState.sort = viewState.sort === 'original' ? 'year' : 'original';
renderState();
});
}
};
renderState();
}
function renderVolunteer(volunteer) {
const titleEl = document.getElementById('volunteer-title');
const container = document.getElementById('volunteer-timeline');
if (titleEl && volunteer.titleHTML) {
titleEl.innerHTML = volunteer.titleHTML;
}
if (!container || !volunteer.timeline) {
return;
}
const iconLibrary = window.siteIcons || {};
container.innerHTML = (volunteer.timeline.items || []).map(item => {
const iconRef = item.iconKey || item.icon;
const iconConfig = typeof iconRef === 'string' ? iconLibrary[iconRef] : undefined;
let iconHTML = '';
const bodyHTML = item.bodyHTML || '';
const textHTML = `<p class="single-line-text">${bodyHTML}</p>`;
if (iconConfig && iconConfig.src) {
const defaultScale = typeof iconConfig.scale === 'number' ? iconConfig.scale : 100;
const rawScale = typeof item.iconScale === 'number' ? item.iconScale : defaultScale;
const clampedScale = Math.max(0, Math.min(rawScale, 100));
const scaleRatio = clampedScale / 100;
const scaleAttr = scaleRatio !== 1 ? ` style="--icon-image-scale: ${scaleRatio};"` : '';
const altText = iconConfig.alt || '';
iconHTML = `
<div class="timeline-icon">
<div class="timeline-icon-inner"${scaleAttr}>
<img src="${iconConfig.src}" alt="${altText}">
</div>
</div>
`;
}
if (iconHTML) {
return `
<div class="card timeline-card single-line-card">
${iconHTML}
${textHTML}
</div>
`;
} else {
return `
<div class="card timeline-card talk-item">
<p>${item.bodyHTML || ''}</p>
</div>
`;
}
}).join('');
}
function renderAwards(awards) {
const titleEl = document.getElementById('awards-title');
const introEl = document.getElementById('awards-intro');
const container = document.getElementById('awards-timeline');
if (titleEl && awards.titleHTML) {
titleEl.innerHTML = awards.titleHTML;
}
if (introEl && awards.intro) {
introEl.innerHTML = awards.intro;
}
if (!container || !awards.timeline) {
return;
}
const iconLibrary = window.siteIcons || {};
container.innerHTML = (awards.timeline.items || []).map(item => {
const iconRef = item.iconKey || item.icon;
const iconConfig = typeof iconRef === 'string' ? iconLibrary[iconRef] : undefined;
let iconHTML = '';
const bodyHTML = item.bodyHTML || '';
const textHTML = `<p class="single-line-text">${bodyHTML}</p>`;
if (iconConfig && iconConfig.src) {
const defaultScale = typeof iconConfig.scale === 'number' ? iconConfig.scale : 100;
const rawScale = typeof item.iconScale === 'number' ? item.iconScale : defaultScale;
const clampedScale = Math.max(0, Math.min(rawScale, 100));
const scaleRatio = clampedScale / 100;
const scaleAttr = scaleRatio !== 1 ? ` style="--icon-image-scale: ${scaleRatio};"` : '';
const altText = iconConfig.alt || '';
iconHTML = `
<div class="timeline-icon">
<div class="timeline-icon-inner"${scaleAttr}>
<img src="${iconConfig.src}" alt="${altText}">
</div>
</div>
`;
}
if (iconHTML) {
return `
<div class="card timeline-card single-line-card">
${iconHTML}
${textHTML}
</div>
`;
} else {
return `
<div class="card timeline-card talk-item">
<p>${item.bodyHTML || ''}</p>
</div>
`;
}
}).join('');
}
function renderPublications(pageContent) {
const titleEl = document.getElementById('publications-title');
const introEl = document.getElementById('publications-intro');
if (titleEl && pageContent.titleHTML) {
titleEl.innerHTML = pageContent.titleHTML;
}
if (introEl && pageContent.intro) {
introEl.innerHTML = pageContent.intro;
}
renderScholarProfileSection(pageContent.scholarProfile);
}
function renderScholarProfileSection(scholarData) {
const root = document.getElementById('scholar-profile-root');
if (!root) {
return;
}
const profile = scholarData?.profile || window.PROFILE;
const publications = Array.isArray(scholarData?.publications)
? scholarData.publications
: (Array.isArray(window.PUBLICATIONS) ? window.PUBLICATIONS : []);
const sortedPublications = sortScholarPublications(publications);
if (!profile) {
console.warn('Scholar profile data missing: expected local scholar data or window.PROFILE object');
root.style.display = 'none';
return;
}
window.__scholarChartProfile = profile;
renderScholarMeta(scholarData);
renderScholarPublicationsList(sortedPublications);
renderScholarStats(profile);
renderScholarCoauthors(profile);
setupScholarViewSwitcher(profile);
requestAnimationFrame(() => {
scheduleScholarCitationGraph(profile, 'all');
attachScholarChartResize(profile);
});
}
function renderScholarMeta(scholarData) {
const metaEl = document.getElementById('scholar-profile-meta');
if (!metaEl) {
return;
}
const lastUpdated = scholarData?.lastUpdated;
if (!lastUpdated) {
metaEl.innerHTML = '';
metaEl.hidden = true;
return;
}
const parsedDate = new Date(`${lastUpdated}T00:00:00`);
const formattedDate = Number.isNaN(parsedDate.getTime())
? lastUpdated
: new Intl.DateTimeFormat('en-US', {
month: 'long',
day: 'numeric',
year: 'numeric'
}).format(parsedDate);
metaEl.innerHTML = `<span class="scholar-last-updated">Updated ${formattedDate}</span>`;
metaEl.hidden = false;
}
function renderScholarPublicationsList(publications) {
const container = document.getElementById('scholar-publications-list');
if (!container) {
return;
}
if (!publications.length) {
container.classList.add('scholar-publications-empty');
container.textContent = 'No publications available.';
return;
}
container.classList.remove('scholar-publications-empty');
const total = publications.length;
const visibleCap = 5; // show top 5 only
if (total <= visibleCap) {
container.innerHTML = publications.map(publication => buildPublicationRow(publication)).join('');
return;
}
const leading = publications.slice(0, visibleCap);
const hidden = publications.slice(visibleCap);
const hiddenCount = hidden.length;
let html = leading.map(publication => buildPublicationRow(publication)).join('');
html += '<div class="scholar-ellipsis-row" data-ellipsis="true">…</div>';
html += hidden.map(publication => buildHiddenPublicationRow(publication)).join('');
html += `<div class="scholar-toggle-row"><button type="button" class="scholar-toggle-button" data-state="collapsed">Show more ${hiddenCount} ${formatScholarPaperCount(hiddenCount)}</button></div>`;
container.innerHTML = html;
const hiddenRows = Array.from(container.querySelectorAll('.scholar-paper-row-hidden'));
hiddenRows.forEach(row => {
row.style.display = 'none';
});
const ellipsisRow = container.querySelector('.scholar-ellipsis-row');
const toggleButton = container.querySelector('.scholar-toggle-button');
if (toggleButton) {
toggleButton.addEventListener('click', () => {
const expanded = toggleButton.dataset.state === 'expanded';
if (expanded) {
hiddenRows.forEach(row => {
row.style.display = 'none';
});
if (ellipsisRow) {
ellipsisRow.style.display = '';
}
toggleButton.dataset.state = 'collapsed';
toggleButton.textContent = `Show more ${hiddenCount} ${formatScholarPaperCount(hiddenCount)}`;
} else {
hiddenRows.forEach(row => {
row.style.display = '';
});
if (ellipsisRow) {
ellipsisRow.style.display = 'none';
}
toggleButton.dataset.state = 'expanded';
toggleButton.textContent = `Hide ${hiddenCount} ${formatScholarPaperCount(hiddenCount)}`;
}
});
}
}
function sortScholarPublications(publications) {
return publications.slice().sort((left, right) => {
const leftCitations = Number(left?.cited_by) || 0;
const rightCitations = Number(right?.cited_by) || 0;
if (rightCitations !== leftCitations) {
return rightCitations - leftCitations;
}
const leftYear = Number(left?.year) || 0;
const rightYear = Number(right?.year) || 0;
if (rightYear !== leftYear) {
return rightYear - leftYear;
}
return (left?.title || '').localeCompare(right?.title || '');
});
}
function buildPublicationRow(publication) {
const title = publication.url
? `<a class="scholar-paper-title" href="${publication.url}" target="_blank" rel="noopener noreferrer">${publication.title}</a>`
: `<span class="scholar-paper-title">${publication.title}</span>`;
const authors = `<div class="scholar-paper-authors">${publication.authors || ''}</div>`;
const venue = `<div class="scholar-paper-venue">${publication.venue || ''}</div>`;
const badges = buildPublicationBadges(publication);
const citedBy = publication.cited_by === undefined || publication.cited_by === null
? ''
: publication.citations_url
? `<a href="${publication.citations_url}" target="_blank" rel="noopener noreferrer">${publication.cited_by}</a>`
: `<span>${publication.cited_by}</span>`;
const year = publication.year ? publication.year : '';
return `
<div class="scholar-paper-row">
<div class="scholar-paper-content">
${title}
${authors}
${venue}
${badges}
</div>
<div class="scholar-paper-cited">${citedBy}</div>
<div class="scholar-paper-year">${year}</div>
</div>
`;
}
function buildPublicationBadges(publication) {
const segments = [];
const authorsText = (publication.authors || '').trim();
const isFirstAuthor = authorsText.startsWith('H Joko') ||
authorsText.startsWith('H JOKO') ||
authorsText.startsWith('城光英彰');
if (isFirstAuthor) {
segments.push('<span class="scholar-badge scholar-badge-1st"><strong>✍️ First Author</strong></span>');
}
if (publication.ranking) {
const emoji = publication.ranking === 'A*' ? '🌟' : '⭐';
segments.push(`<span class="scholar-badge scholar-badge-ranking"><strong>${emoji} ${publication.ranking} Conference</strong></span>`);
}
if (publication.type === 'patent') {
segments.push('<span class="scholar-badge scholar-badge-patent"><strong>💡 Patent</strong></span>');
}
if (publication.type === 'journal') {
segments.push('<span class="scholar-badge scholar-badge-journal"><strong>📖 Journal</strong></span>');
}
if (publication.downloads) {
const text = `⬇️ ${publication.downloads} Downloads`;
if (publication.downloadsUrl) {
segments.push(`
<a class="scholar-badge scholar-badge-download" href="${publication.downloadsUrl}" target="_blank" rel="noopener noreferrer"><strong>${text}</strong></a>
`);
} else {
segments.push(`<span class="scholar-badge scholar-badge-download"><strong>${text}</strong></span>`);
}
}
if (publication.downloads_top_percent) {
segments.push(`
<a class="scholar-badge scholar-badge-top-download" href="https://hideaki-j.github.io/conference-statistics/" target="_blank" rel="noopener noreferrer"><strong>🔥 ${publication.downloads_top_percent}</strong></a>
`);
}
if (publication.award) {
segments.push(`<span class="scholar-badge scholar-badge-award"><strong>${publication.award}</strong></span>`);
}
if (!segments.length) {
return '';
}
return `<div class="scholar-badges">${segments.join('')}</div>`;
}
function buildHiddenPublicationRow(publication) {
const rowHTML = buildPublicationRow(publication);
return rowHTML.replace('class="scholar-paper-row"', 'class="scholar-paper-row scholar-paper-row-hidden"');
}
function renderScholarStats(profile) {
const citations = profile.citations || {};
const all = citations.all || {};
window.__scholarChartMode = 'all';
const setText = (id, value) => {
const el = document.getElementById(id);
if (el) {
el.textContent = value !== undefined && value !== null && value !== '' ? value : '—';
}
};
setText('scholar-citations-all', all.citations);
const citationHeading = document.getElementById('citation-heading');
if (citationHeading) {
citationHeading.textContent = 'Total Citations';
}
}
function renderScholarCoauthors(profile) {