Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
1154 lines (1004 loc) · 33.3 KB
/
Copy pathapp.js
File metadata and controls
1154 lines (1004 loc) · 33.3 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
(async function () {
const manifest = window.LAB_PAPERS_DATA || {};
const bundle = window.LAB_PAPERS_BUNDLE;
const state = {
selectedCCF: "ALL",
selectedCORE: "ALL",
selectedTHCPL: "ALL",
selectedNCS: "ALL",
selectedSCI: "ALL",
selectedField: "ALL",
selectedDirection: "ALL",
selectedYear: "ALL",
selectedType: "ALL",
yearSortOrder: "DESC",
searchQuery: "",
};
const CCF_COLORS = {
A: "#c52b2b",
B: "#e88b25",
C: "#159a53",
N: "#94a3b8",
};
const CHIP_TONES = {
ccf: {
ALL: "chip--blue",
A: "chip--red",
B: "chip--orange",
C: "chip--green",
N: "chip--slate",
},
core: {
ALL: "chip--blue",
"A*": "chip--purple",
A: "chip--indigo",
B: "chip--sky",
C: "chip--teal",
N: "chip--slate",
},
thcpl: {
ALL: "chip--blue",
A: "chip--rose",
B: "chip--amber",
N: "chip--slate",
},
ncs: {
ALL: "chip--blue",
NCS: "chip--purple",
NCS_SUB: "chip--indigo",
},
sci: {
ALL: "chip--blue",
SCI1: "chip--teal",
SCI2: "chip--sky",
SCI3: "chip--slate",
},
field: "chip--blue",
direction: "chip--indigo",
year: "chip--blue",
type: "chip--indigo",
};
const BADGE_CLASSES = {
ccf: {
A: "badge--ccf-a",
B: "badge--ccf-b",
C: "badge--ccf-c",
N: "badge--ccf-none",
},
core: {
"A*": "badge--core-star",
A: "badge--core-a",
B: "badge--core-b",
C: "badge--core-c",
N: "badge--ccf-none",
},
thcpl: {
A: "badge--thcpl-a",
B: "badge--thcpl-b",
N: "badge--ccf-none",
},
ncs: {
NCS: "badge--ncs-main",
NCS_SUB: "badge--ncs-sub",
},
sci: {
SCI1: "badge--sci-1",
SCI2: "badge--sci-2",
SCI3: "badge--sci-3",
},
};
const DIRECTION_BADGES = {
"网络与算网融合": "badge--direction-blue",
"隐私计算": "badge--direction-violet",
"大模型推理与训练": "badge--direction-amber",
"量子智能": "badge--direction-cyan",
"医学智能": "badge--direction-rose",
"脑机与生成式智能": "badge--direction-fuchsia",
"AI for Science": "badge--direction-lime",
};
const elements = {
summaryStats: document.getElementById("summaryStats"),
yearChart: document.getElementById("yearChart"),
ccfChart: document.getElementById("ccfChart"),
searchInput: document.getElementById("searchInput"),
filterRows: document.getElementById("filterRows"),
clearFiltersBtn: document.getElementById("clearFiltersBtn"),
resultsCount: document.getElementById("resultsCount"),
activeSummary: document.getElementById("activeSummary"),
sortControls: document.getElementById("sortControls"),
papersList: document.getElementById("papersList"),
};
let dataset = null;
let papers = [];
let years = [];
let mainEventsBound = false;
try {
if (!bundle || !Array.isArray(bundle.papers)) {
throw new Error("papers-data.js format is invalid");
}
applyDataset(createBundledDataset(manifest, bundle));
} catch (error) {
console.error(error);
renderFatalState(error);
}
function applyDataset(nextDataset) {
dataset = enrichDataset(nextDataset);
papers = dataset.papers.slice();
years = Array.from(new Set(papers.map(function (paper) { return paper.year; }))).sort(function (left, right) {
return right - left;
});
if (!mainEventsBound) {
bindMainEvents();
mainEventsBound = true;
}
renderStats();
renderFilters();
renderResults();
}
function bindMainEvents() {
elements.searchInput.addEventListener("input", function (event) {
state.searchQuery = event.target.value;
renderResults();
});
elements.filterRows.addEventListener("click", function (event) {
const button = event.target.closest("[data-filter]");
if (!button) {
return;
}
const key = button.dataset.filter;
const rawValue = button.dataset.value;
if (!key) {
return;
}
if (key === "selectedYear") {
state.selectedYear = rawValue === "ALL" ? "ALL" : Number(rawValue);
} else {
state[key] = rawValue;
}
renderFilters();
renderResults();
});
elements.clearFiltersBtn.addEventListener("click", function () {
resetState();
renderFilters();
renderResults();
});
elements.sortControls.addEventListener("click", function (event) {
const button = event.target.closest("[data-sort-order]");
if (!button) {
return;
}
state.yearSortOrder = button.dataset.sortOrder === "ASC" ? "ASC" : "DESC";
renderSortControls();
renderResults();
});
elements.papersList.addEventListener("error", function (event) {
const image = event.target;
if (!(image instanceof HTMLImageElement)) {
return;
}
const figure = image.closest(".paper-card__figure");
const media = figure ? figure.querySelector(".paper-card__figure-media") : null;
const figureFile = figure ? figure.dataset.figureFile : "";
if (!figure || !media || figure.classList.contains("is-missing")) {
return;
}
figure.classList.add("is-missing");
media.innerHTML =
'<div class="paper-card__figure-placeholder">' +
"<strong>本地 PNG 未找到</strong>" +
"</div>";
}, true);
}
function resetState() {
state.selectedCCF = "ALL";
state.selectedCORE = "ALL";
state.selectedTHCPL = "ALL";
state.selectedNCS = "ALL";
state.selectedSCI = "ALL";
state.selectedField = "ALL";
state.selectedDirection = "ALL";
state.selectedYear = "ALL";
state.selectedType = "ALL";
state.searchQuery = "";
elements.searchInput.value = "";
}
function renderStats() {
const totalCount = papers.length;
const ccfACount = papers.filter(function (paper) { return paper.ccf === "A"; }).length;
const coreACount = papers.filter(function (paper) { return paper.core === "A*" || paper.core === "A"; }).length;
const thcplACount = papers.filter(function (paper) { return paper.thcpl === "A"; }).length;
const journalCount = papers.filter(function (paper) { return paper.type === "journal"; }).length;
const ncsCount = papers.filter(function (paper) { return paper.ncsCategory === "NCS"; }).length;
const ncsSubCount = papers.filter(function (paper) { return paper.ncsCategory === "NCS_SUB"; }).length;
const sci1Count = papers.filter(function (paper) { return paper.sciZone === "SCI1"; }).length;
const sci2Count = papers.filter(function (paper) { return paper.sciZone === "SCI2"; }).length;
const sci3Count = papers.filter(function (paper) { return paper.sciZone === "SCI3"; }).length;
const cards = [
{ label: "总论文数", value: totalCount, tone: "blue" },
{ label: "CCF A 类", value: ccfACount, tone: "red" },
{ label: "CORE A / A*", value: coreACount, tone: "gold" },
{ label: "THCPL A 类", value: thcplACount, tone: "rose" },
{ label: "NCS", note: "(nature, cell, science)", value: ncsCount, tone: "violet" },
{ label: "NCS子刊", value: ncsSubCount, tone: "indigo" },
{ label: "SCI 1区", value: sci1Count, tone: "teal" },
{ label: "SCI 2区", value: sci2Count, tone: "sky" },
];
elements.summaryStats.innerHTML = cards
.map(function (card) {
return (
'<article class="stat-card stat-card--' +
card.tone +
'">' +
'<span class="stat-card__value">' +
card.value +
"</span>" +
'<span class="stat-card__label">' +
escapeHtml(card.label) +
(card.note ? '<small class="stat-card__note">' + escapeHtml(card.note) + "</small>" : "") +
"</span>" +
"</article>"
);
})
.join("");
renderYearChart();
renderCCFChart();
}
function renderYearChart() {
const yearMap = new Map();
papers.forEach(function (paper) {
yearMap.set(paper.year, (yearMap.get(paper.year) || 0) + 1);
});
const chartData = Array.from(yearMap.entries())
.sort(function (left, right) {
return left[0] - right[0];
})
.map(function (entry) {
return { year: entry[0], count: entry[1] };
});
const maxCount = Math.max.apply(
null,
chartData.map(function (item) {
return item.count;
}),
);
const yearRow = chartData
.map(function (item) {
return '<td class="year-chart__year-cell">' + item.year + "</td>";
})
.join("");
const barRow = chartData
.map(function (item) {
const height = maxCount ? Math.max(10, Math.round((item.count / maxCount) * 100)) : 0;
return (
'<td class="year-chart__bar-cell">' +
'<div class="year-chart__bar-track">' +
'<div class="year-chart__bar-fill" style="--bar-height:' +
height +
'%;"></div>' +
"</div>" +
"</td>"
);
})
.join("");
const countRow = chartData
.map(function (item) {
return '<td class="year-chart__count">' + item.count + "</td>";
})
.join("");
elements.yearChart.innerHTML =
'<table class="year-chart__table">' +
"<tbody>" +
'<tr><th class="year-chart__label" scope="row">年份</th>' +
yearRow +
"</tr>" +
'<tr><th class="year-chart__label" scope="row">趋势</th>' +
barRow +
"</tr>" +
'<tr><th class="year-chart__label" scope="row">篇数</th>' +
countRow +
"</tr>" +
"</tbody>" +
"</table>";
}
function renderCCFChart() {
const order = ["A", "B", "C", "N"];
const totals = { A: 0, B: 0, C: 0, N: 0 };
papers.forEach(function (paper) {
totals[paper.ccf] = (totals[paper.ccf] || 0) + 1;
});
const totalCount = papers.length;
const radius = 54;
const circumference = 2 * Math.PI * radius;
let offset = 0;
const segments = order
.map(function (grade) {
const value = totals[grade];
const length = totalCount ? (value / totalCount) * circumference : 0;
const circle =
'<circle class="ccf-chart__segment" cx="70" cy="70" r="' +
radius +
'" stroke="' +
CCF_COLORS[grade] +
'" stroke-dasharray="' +
length.toFixed(3) +
" " +
circumference.toFixed(3) +
'" stroke-dashoffset="' +
(-offset).toFixed(3) +
'"></circle>';
offset += length;
return circle;
})
.join("");
const legend = order
.map(function (grade) {
return (
'<div class="legend-item">' +
'<span class="legend-item__dot" style="background:' +
CCF_COLORS[grade] +
';"></span>' +
'<span class="legend-item__name">' +
escapeHtml(grade === "N" ? "非 CCF" : "CCF " + grade) +
"</span>" +
'<span class="legend-item__value">' +
totals[grade] +
"</span>" +
"</div>"
);
})
.join("");
elements.ccfChart.innerHTML =
'<div class="ccf-chart__wrap">' +
'<div class="ccf-chart__donut">' +
'<svg viewBox="0 0 140 140" role="img" aria-hidden="true">' +
'<circle class="ccf-chart__ring-bg" cx="70" cy="70" r="' +
radius +
'"></circle>' +
segments +
"</svg>" +
'<div class="ccf-chart__center"><div><strong>' +
totalCount +
'</strong><span>篇论文</span></div></div>' +
"</div>" +
'<div class="ccf-chart__legend"><div class="legend-list">' +
legend +
"</div></div>" +
"</div>";
}
function renderFilters() {
elements.filterRows.innerHTML = [
createFilterRow(
"CCF 等级",
createOptionButtons(
["ALL", "A", "B", "C", "N"],
"selectedCCF",
function (value) {
if (value === "ALL") {
return "全部";
}
return value === "N" ? "非 CCF" : "CCF " + value;
},
function (value) {
return value === "ALL" ? papers.length : papers.filter(function (paper) { return paper.ccf === value; }).length;
},
state.selectedCCF,
function (value) {
return CHIP_TONES.ccf[value];
},
),
),
createFilterRow(
"CORE 等级",
createOptionButtons(
["ALL", "A*", "A", "B", "C", "N"],
"selectedCORE",
function (value) {
if (value === "ALL") {
return "全部";
}
return value === "N" ? "非 CORE" : "CORE " + value;
},
function (value) {
return value === "ALL" ? papers.length : papers.filter(function (paper) { return paper.core === value; }).length;
},
state.selectedCORE,
function (value) {
return CHIP_TONES.core[value];
},
),
),
createFilterRow(
"THCPL 等级",
createOptionButtons(
["ALL", "A", "B", "N"],
"selectedTHCPL",
function (value) {
if (value === "ALL") {
return "全部";
}
return value === "N" ? "非 THCPL" : "THCPL " + value;
},
function (value) {
return value === "ALL" ? papers.length : papers.filter(function (paper) { return paper.thcpl === value; }).length;
},
state.selectedTHCPL,
function (value) {
return CHIP_TONES.thcpl[value];
},
),
),
createFilterRow(
"NCS 标签",
createOptionButtons(
["ALL"].concat(dataset.ncsCategories),
"selectedNCS",
function (value) {
return value === "ALL" ? "全部" : getNCSLabel(value);
},
function (value) {
return value === "ALL" ? papers.length : papers.filter(function (paper) { return paper.ncsCategory === value; }).length;
},
state.selectedNCS,
function (value) {
return CHIP_TONES.ncs[value];
},
),
),
createFilterRow(
"SCI 分区",
createOptionButtons(
["ALL"].concat(dataset.sciZones),
"selectedSCI",
function (value) {
return value === "ALL" ? "全部" : getSCILabel(value);
},
function (value) {
return value === "ALL" ? papers.length : papers.filter(function (paper) { return paper.sciZone === value; }).length;
},
state.selectedSCI,
function (value) {
return CHIP_TONES.sci[value];
},
),
),
createFilterRow(
"研究领域",
createOptionButtons(
["ALL"].concat(dataset.ccfFields),
"selectedField",
function (value) {
return value === "ALL" ? "全部" : dataset.ccfFieldAbbr[value];
},
null,
state.selectedField,
function () {
return CHIP_TONES.field;
},
),
),
createFilterRow(
"研究方向",
createOptionButtons(
["ALL"].concat(dataset.researchDirections),
"selectedDirection",
function (value) {
return value === "ALL" ? "全部" : value;
},
null,
state.selectedDirection,
function () {
return CHIP_TONES.direction;
},
),
),
createFilterRow(
"年份 / 类型",
createOptionButtons(
["ALL"].concat(years),
"selectedYear",
function (value) {
return value === "ALL" ? "全部年份" : String(value);
},
null,
state.selectedYear,
function () {
return CHIP_TONES.year;
},
) +
createOptionButtons(
["ALL", "journal", "conference"],
"selectedType",
function (value) {
if (value === "ALL") {
return "全部类型";
}
return value === "journal" ? "期刊" : "会议";
},
null,
state.selectedType,
function () {
return CHIP_TONES.type;
},
),
),
].join("");
}
function createFilterRow(label, chips) {
return (
'<div class="filter-row">' +
'<div class="filter-row__label">' +
escapeHtml(label) +
"</div>" +
'<div class="filter-row__chips">' +
chips +
"</div>" +
"</div>"
);
}
function createOptionButtons(options, key, labelResolver, countResolver, activeValue, toneResolver) {
return options
.map(function (value) {
const isActive = String(activeValue) === String(value);
const count = typeof countResolver === "function" ? countResolver(value) : null;
const toneClass = toneResolver(value);
return (
'<button type="button" class="chip ' +
toneClass +
(isActive ? " is-active" : "") +
'" data-filter="' +
escapeAttribute(key) +
'" data-value="' +
escapeAttribute(String(value)) +
'">' +
'<span>' +
escapeHtml(labelResolver(value)) +
"</span>" +
(count === null ? "" : '<span class="chip__count">(' + count + ")</span>") +
"</button>"
);
})
.join("");
}
function renderResults() {
const filteredPapers = getFilteredPapers();
const hasCriteria = hasActiveCriteria();
elements.resultsCount.innerHTML =
'显示 <strong>' + filteredPapers.length + "</strong> / " + papers.length + " 篇论文";
elements.activeSummary.textContent = buildActiveSummary(filteredPapers.length);
elements.clearFiltersBtn.hidden = !hasCriteria;
renderSortControls();
if (!papers.length) {
elements.papersList.innerHTML =
'<div class="empty-state">' +
"<h3>论文数据未加载成功</h3>" +
"<p>请检查 data.js、datas 目录,以及是否通过本地 HTTP 服务打开了页面。</p>" +
"</div>";
return;
}
if (!filteredPapers.length) {
elements.papersList.innerHTML =
'<div class="empty-state">' +
"<h3>没有找到符合条件的论文</h3>" +
"<p>可以尝试放宽筛选条件,或点击上方“清除筛选”恢复全部论文。</p>" +
"</div>";
return;
}
elements.papersList.innerHTML = filteredPapers
.map(function (paper) {
return renderPaperCard(paper);
})
.join("");
}
function getFilteredPapers() {
const query = state.searchQuery.trim().toLowerCase();
return papers.filter(function (paper) {
if (state.selectedCCF !== "ALL" && paper.ccf !== state.selectedCCF) {
return false;
}
if (state.selectedCORE !== "ALL" && paper.core !== state.selectedCORE) {
return false;
}
if (state.selectedTHCPL !== "ALL" && paper.thcpl !== state.selectedTHCPL) {
return false;
}
if (state.selectedNCS !== "ALL" && paper.ncsCategory !== state.selectedNCS) {
return false;
}
if (state.selectedSCI !== "ALL" && paper.sciZone !== state.selectedSCI) {
return false;
}
if (state.selectedField !== "ALL" && !paper.fields.includes(state.selectedField)) {
return false;
}
if (state.selectedDirection !== "ALL" && !paper.researchDirections.includes(state.selectedDirection)) {
return false;
}
if (state.selectedYear !== "ALL" && paper.year !== state.selectedYear) {
return false;
}
if (state.selectedType !== "ALL" && paper.type !== state.selectedType) {
return false;
}
if (!query) {
return true;
}
return [
paper.title,
paper.authors,
paper.venue,
paper.abstract,
paper.researchDirections.join(" "),
getNCSLabel(paper.ncsCategory),
getSCILabel(paper.sciZone),
].some(function (value) {
return String(value).toLowerCase().includes(query);
});
}).sort(function (left, right) {
if (left.year !== right.year) {
return state.yearSortOrder === "ASC" ? left.year - right.year : right.year - left.year;
}
return left.title.localeCompare(right.title);
});
}
function hasActiveCriteria() {
return (
state.selectedCCF !== "ALL" ||
state.selectedCORE !== "ALL" ||
state.selectedTHCPL !== "ALL" ||
state.selectedNCS !== "ALL" ||
state.selectedSCI !== "ALL" ||
state.selectedField !== "ALL" ||
state.selectedDirection !== "ALL" ||
state.selectedYear !== "ALL" ||
state.selectedType !== "ALL" ||
state.searchQuery.trim() !== ""
);
}
function buildActiveSummary(filteredCount) {
const parts = [];
let summary = "";
if (state.selectedCCF !== "ALL") {
parts.push(state.selectedCCF === "N" ? "非 CCF" : "CCF " + state.selectedCCF);
}
if (state.selectedCORE !== "ALL") {
parts.push(state.selectedCORE === "N" ? "非 CORE" : "CORE " + state.selectedCORE);
}
if (state.selectedTHCPL !== "ALL") {
parts.push(state.selectedTHCPL === "N" ? "非 THCPL" : "THCPL " + state.selectedTHCPL);
}
if (state.selectedNCS !== "ALL") {
parts.push(getNCSLabel(state.selectedNCS));
}
if (state.selectedSCI !== "ALL") {
parts.push(getSCILabel(state.selectedSCI));
}
if (state.selectedField !== "ALL") {
parts.push(dataset.ccfFieldAbbr[state.selectedField]);
}
if (state.selectedDirection !== "ALL") {
parts.push(state.selectedDirection);
}
if (state.selectedYear !== "ALL") {
parts.push(String(state.selectedYear));
}
if (state.selectedType !== "ALL") {
parts.push(state.selectedType === "journal" ? "期刊" : "会议");
}
if (state.searchQuery.trim()) {
parts.push('搜索 "' + state.searchQuery.trim() + '"');
}
if (!parts.length) {
summary = "当前展示全部论文";
} else {
summary = "当前条件:" + parts.join(" · ");
}
summary += " · 命中 " + filteredCount + " 篇";
summary += state.yearSortOrder === "ASC" ? " · 年份升序" : " · 年份降序";
if (dataset.failedFiles.length) {
summary += " · 未加载 " + dataset.failedFiles.length + " 篇数据";
}
return summary;
}
function renderPaperCard(paper) {
const badges = [];
const abstractText = paper.abstract.trim() || "暂无摘要";
const figureFile = paper.id + ".png";
const abstractClass = paper.abstract.trim() ? "paper-abstract" : "paper-abstract is-placeholder";
if (paper.ccf && paper.ccf !== "N") {
badges.push(renderBadge("CCF " + paper.ccf, BADGE_CLASSES.ccf[paper.ccf] || "badge--ccf-none"));
}
if (paper.core && paper.core !== "N") {
badges.push(renderBadge("CORE " + paper.core, BADGE_CLASSES.core[paper.core] || "badge--ccf-none"));
}
if (paper.thcpl && paper.thcpl !== "N") {
badges.push(renderBadge("THCPL " + paper.thcpl, BADGE_CLASSES.thcpl[paper.thcpl] || "badge--ccf-none"));
}
if (paper.type === "journal" && paper.ncsCategory !== "NONE") {
badges.push(renderBadge(getNCSLabel(paper.ncsCategory), BADGE_CLASSES.ncs[paper.ncsCategory] || "badge--soft"));
}
if (paper.type === "journal" && paper.sciZone !== "NONE") {
badges.push(renderBadge(getSCILabel(paper.sciZone), BADGE_CLASSES.sci[paper.sciZone] || "badge--soft"));
}
badges.push(renderBadge(paper.type === "journal" ? "期刊" : "会议", "badge--muted"));
paper.researchDirections.forEach(function (direction) {
badges.push(renderBadge(direction, DIRECTION_BADGES[direction] || "badge--soft"));
});
if (paper.accepted) {
badges.push(renderBadge("已录用", "badge--accepted"));
}
const metaItems = [
'<span class="paper-card__venue">' + escapeHtml(paper.venue) + "</span>",
"<span>" + paper.year + "</span>",
]
.concat(
paper.fields.map(function (field) {
return '<span class="field-tag">' + escapeHtml(dataset.ccfFieldAbbr[field] || field) + "</span>";
}),
)
.concat(
[paper.link ? { label: "原文链接", href: paper.link } : null, paper.pdf ? { label: "PDF", href: paper.pdf } : null, paper.doi ? { label: "DOI", href: paper.doi } : null]
.filter(Boolean)
.map(function (link) {
return '<a class="paper-card__meta-link" href="' + escapeAttribute(link.href) + '" target="_blank" rel="noreferrer">' + escapeHtml(link.label) + "</a>";
}),
)
.join("");
return (
'<article class="paper-card">' +
'<div class="paper-card__body">' +
'<div class="paper-card__badges">' +
badges.join("") +
"</div>" +
'<h3 class="paper-card__title">' +
escapeHtml(paper.title) +
"</h3>" +
'<p class="paper-card__authors">' +
escapeHtml(paper.authors) +
"</p>" +
'<div class="paper-card__meta">' +
metaItems +
"</div>" +
'<div class="paper-card__content">' +
'<section class="paper-card__panel paper-card__panel--abstract">' +
'<div class="paper-card__panel-head"><span>摘要</span></div>' +
'<p class="' +
abstractClass +
'">' +
escapeHtml(abstractText) +
"</p>" +
"</section>" +
'<figure class="paper-card__panel paper-card__figure" data-figure-file="' +
escapeAttribute(figureFile) +
'">' +
'<div class="paper-card__panel-head"><span>图片</span></div>' +
'<div class="paper-card__figure-media">' +
'<img src="' +
escapeAttribute(paper.figurePath) +
'" alt="' +
escapeAttribute(paper.title + " 本地图") +
'" loading="lazy">' +
"</div>" +
"</figure>" +
"</div>" +
"</div>" +
"</article>"
);
}
function renderBadge(label, className) {
return '<span class="badge ' + className + '">' + escapeHtml(label) + "</span>";
}
function renderSortControls() {
if (!elements.sortControls) {
return;
}
const buttons = elements.sortControls.querySelectorAll("[data-sort-order]");
buttons.forEach(function (button) {
const isActive = button.dataset.sortOrder === state.yearSortOrder;
button.classList.toggle("is-active", isActive);
button.setAttribute("aria-pressed", String(isActive));
});
}
async function loadDataset(sourceManifest) {
if (!sourceManifest || !Array.isArray(sourceManifest.paperFiles)) {
throw new Error("LAB_PAPERS_DATA.paperFiles is missing. Please check data.js.");
}
const results = await Promise.allSettled(
sourceManifest.paperFiles.map(function (fileId) {
return loadPaperFile(fileId);
}),
);
const loadedPapers = [];
const failedFiles = [];
results.forEach(function (result, index) {
if (result.status === "fulfilled") {
loadedPapers.push(result.value);
} else {
failedFiles.push(sourceManifest.paperFiles[index]);
}
});
if (!loadedPapers.length && window.location.protocol === "file:") {
const localFileError = new Error("浏览器在 file:// 模式下拦截了 datas/*.json 的自动读取。");
localFileError.code = "LOCAL_JSON_BLOCKED";
throw localFileError;
}
return {
ccfFields: sourceManifest.ccfFields || [],
researchDirections: sourceManifest.researchDirections || [],
ncsCategories: sourceManifest.ncsCategories || [],
sciZones: sourceManifest.sciZones || [],
ccfFieldAbbr: sourceManifest.ccfFieldAbbr || {},
failedFiles: failedFiles,
papers: loadedPapers,
};
}
function createBundledDataset(sourceManifest, bundlePayload) {
const bundledPapers = Array.isArray(bundlePayload.papers) ? bundlePayload.papers : [];
return {
ccfFields: bundlePayload.ccfFields || sourceManifest.ccfFields || [],
researchDirections: bundlePayload.researchDirections || sourceManifest.researchDirections || [],
ncsCategories: bundlePayload.ncsCategories || sourceManifest.ncsCategories || [],
sciZones: bundlePayload.sciZones || sourceManifest.sciZones || [],
ccfFieldAbbr: bundlePayload.ccfFieldAbbr || sourceManifest.ccfFieldAbbr || {},
failedFiles: [],
papers: bundledPapers.map(function (paper) {
return normalizePaper(paper, paper.id || paper.title || "paper");
}),
};
}
function enrichDataset(sourceDataset) {
const fields = [];
const directions = [];
const seenFields = new Set();
const seenDirections = new Set();
(sourceDataset.ccfFields || []).forEach(function (field) {
if (!field || seenFields.has(field)) {
return;
}
seenFields.add(field);
fields.push(field);
});
(sourceDataset.researchDirections || []).forEach(function (direction) {
if (!direction || seenDirections.has(direction)) {
return;
}
seenDirections.add(direction);
directions.push(direction);
});
sourceDataset.papers.forEach(function (paper) {
paper.fields.forEach(function (field) {
if (!field || seenFields.has(field)) {
return;
}
seenFields.add(field);
fields.push(field);
});
paper.researchDirections.forEach(function (direction) {
if (!direction || seenDirections.has(direction)) {
return;