-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathchinese-map-name-analyzer.html
More file actions
630 lines (546 loc) · 20.9 KB
/
chinese-map-name-analyzer.html
File metadata and controls
630 lines (546 loc) · 20.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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D坦克中文地图高频词分析</title>
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=M+PLUS+1p:wght@400;500;700&family=Rubik:wght@400;500;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0" rel="stylesheet" />
<style>
:root {
/* Palette */
--color-primary: #76FF33;
--color-on-primary: #002200;
--color-background: #001926;
--color-surface: rgba(0, 37, 58, 0.5);
--color-surface-solid: #00253A;
--color-secondary: #BFD5FF;
--color-outline: rgba(191, 213, 255, 0.2);
/* Fonts: Rubik first, M PLUS 1p second */
--font-stack: 'Rubik', 'M PLUS 1p', sans-serif;
--radius-lg: 32px;
--radius-md: 24px;
--radius-full: 999px;
--anim-speed: 0.3s;
--anim-ease: cubic-bezier(0.2, 0, 0, 1);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
-webkit-tap-highlight-color: transparent;
}
body {
background-color: var(--color-background);
color: var(--color-secondary);
font-family: var(--font-stack);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
overflow-x: hidden;
opacity: 0; /* Hidden initially for font loading */
transition: opacity 0.5s ease;
}
body.fonts-loaded {
opacity: 1;
}
/* Loading State */
#loader {
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
display: flex;
justify-content: center;
align-items: center;
background-color: var(--color-background);
z-index: 9999;
transition: opacity 0.5s ease;
pointer-events: none;
}
.spinner {
width: 48px;
height: 48px;
border: 4px solid var(--color-outline);
border-top-color: var(--color-primary);
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Main App */
#app {
width: 100%;
max-width: 800px;
padding: 2rem;
display: flex;
flex-direction: column;
gap: 2rem;
position: relative;
z-index: 1;
}
/* Typography */
h1 {
font-size: 3.5rem;
font-weight: 700;
color: var(--color-primary);
text-align: center;
line-height: 1.1;
letter-spacing: -0.02em;
text-shadow: 0 0 20px rgba(118, 255, 51, 0.15);
margin-bottom: 0.5rem;
}
.subtitle {
text-align: center;
font-size: 1.1rem;
opacity: 0.8;
font-weight: 400;
max-width: 600px;
margin: 0 auto;
}
.highlight-text {
color: var(--color-secondary);
font-weight: 400;
}
/* Glass Panel */
.glass-panel {
background: linear-gradient(145deg, rgba(0, 37, 58, 0.4), rgba(0, 25, 38, 0.6));
border: 1px solid var(--color-outline);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border-radius: var(--radius-lg);
padding: 2rem;
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
display: flex;
flex-direction: column;
gap: 2rem;
min-height: 520px;
position: relative;
overflow: hidden;
transition: transform 0.4s var(--anim-ease);
}
/* Controls */
.controls-area {
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
z-index: 2;
}
.label-small {
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.15em;
color: var(--color-secondary);
opacity: 0.7;
font-weight: 500;
}
.filter-group {
display: flex;
gap: 1rem;
flex-wrap: wrap;
justify-content: center;
}
/* Buttons */
.btn-icon {
width: 3.5rem;
height: 3.5rem;
border-radius: var(--radius-md);
border: 1px solid var(--color-outline);
background: transparent;
color: var(--color-secondary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-family: var(--font-stack);
transition: all 0.3s var(--anim-ease);
}
.btn-icon:hover {
background: rgba(191, 213, 255, 0.05);
border-color: rgba(191, 213, 255, 0.4);
transform: translateY(-2px);
}
.btn-icon.active {
background: var(--color-primary);
color: var(--color-on-primary);
border-color: var(--color-primary);
box-shadow: 0 0 15px rgba(118, 255, 51, 0.3);
transform: scale(1.05);
}
.btn-nav {
width: 3rem;
height: 3rem;
border-radius: var(--radius-full);
border: 1px solid var(--color-outline);
background: transparent;
color: var(--color-secondary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s var(--anim-ease);
}
.btn-nav:hover:not(:disabled) {
background: rgba(118, 255, 51, 0.1);
border-color: var(--color-primary);
color: var(--color-primary);
transform: scale(1.1);
}
.btn-nav:disabled {
opacity: 0.3;
cursor: not-allowed;
border-color: transparent;
transform: scale(1);
}
.material-symbols-rounded {
font-size: 24px;
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
/* Navigation */
.nav-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1rem;
padding: 0 1rem;
}
#position-indicator {
font-variant-numeric: tabular-nums;
letter-spacing: 0.1em;
font-size: 1rem;
font-weight: 500;
color: var(--color-secondary);
opacity: 0.9;
}
/* Content Card */
#display-card {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
opacity: 1;
transform: translateY(0);
transition: opacity 0.2s ease, transform 0.2s ease;
}
#display-card.fading {
opacity: 0;
transform: translateY(10px);
}
.tag {
display: inline-block;
padding: 0.35rem 1rem;
border-radius: var(--radius-full);
background: rgba(118, 255, 51, 0.1);
color: var(--color-primary);
font-size: 0.85rem;
font-weight: 500;
letter-spacing: 0.05em;
margin-bottom: 1.5rem;
border: 1px solid rgba(118, 255, 51, 0.2);
}
.word-title {
font-size: 4.5rem;
font-weight: 700;
color: var(--color-secondary);
margin-bottom: 2rem;
line-height: 1;
background: linear-gradient(180deg, #fff, var(--color-secondary));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.map-list-container {
width: 100%;
max-width: 420px;
background: rgba(0, 0, 0, 0.2);
border-radius: var(--radius-md);
border: 1px solid var(--color-outline);
overflow: hidden;
text-align: left;
box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
}
.map-list-header {
padding: 1rem 1.5rem;
font-size: 0.8rem;
text-transform: uppercase;
color: var(--color-secondary);
opacity: 0.6;
background: rgba(0, 0, 0, 0.2);
letter-spacing: 0.05em;
border-bottom: 1px solid var(--color-outline);
font-weight: 500;
}
.map-list {
max-height: 220px;
overflow-y: auto;
padding: 0.5rem 0;
}
.map-item {
padding: 0.85rem 1.5rem;
font-size: 1rem;
color: rgba(191, 213, 255, 0.9);
border-bottom: 1px solid rgba(191, 213, 255, 0.05);
transition: background 0.2s;
display: block; /* Changed from flex to block to fix copy/paste newlines */
}
.map-item:last-child {
border-bottom: none;
}
.map-item:hover {
background: rgba(118, 255, 51, 0.05);
color: #fff;
}
.highlight-word {
color: var(--color-primary);
font-weight: 700;
margin: 0;
text-shadow: 0 0 10px rgba(118, 255, 51, 0.4);
}
/* Scrollbar */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: rgba(191, 213, 255, 0.1);
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(118, 255, 51, 0.3);
}
/* Empty State */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
opacity: 0.5;
padding: 3rem;
}
/* Responsive */
@media (max-width: 600px) {
h1 { font-size: 2.5rem; }
.word-title { font-size: 3rem; }
#app { padding: 1rem; gap: 1.5rem; }
.glass-panel { padding: 1.5rem; min-height: 400px; }
.btn-icon { width: 3rem; height: 3rem; }
}
</style>
</head>
<body>
<div id="loader">
<div class="spinner"></div>
</div>
<div id="app">
<header>
<h1><span class="highlight-text">3D坦克中文地图高频词分析</span></h1>
<p class="subtitle">中文地图高频命名规律探索</p>
</header>
<main class="glass-panel">
<div class="controls-area">
<span class="label-small">词长筛选</span>
<div id="filters-container" class="filter-group">
<!-- Filters generated by JS -->
</div>
</div>
<div style="flex: 1; display: flex; flex-direction: column; justify-content: space-between;">
<div class="nav-header">
<button id="prev-btn" class="btn-nav" aria-label="上一个">
<span class="material-symbols-rounded">chevron_left</span>
</button>
<span id="position-indicator"></span>
<button id="next-btn" class="btn-nav" aria-label="下一个">
<span class="material-symbols-rounded">chevron_right</span>
</button>
</div>
<div id="display-card">
<!-- Content generated by JS -->
</div>
</div>
</main>
</div>
<script>
// Data
const mapNames = [ "亚历山大罗夫斯克", "群岛", "竞技场", "天空管道", "城镇3C", "柏林巷站", "山城大战", "训练场", "要塞3C", "路桥大战", "黑色营地", "峡谷", "核电站", "切尔努什卡", "科隆", "孔贝", "空中楼阁", "十字路口", "死亡轨道", "甲板9号", "沙漠", "异次元空间", "城镇角斗场", "古代城堡", "爱丁堡", "海滨中心", "遗弃工厂", "农场", "黑色森林", "黑色城堡", "未来世界", "古墓废墟", "铁塔", "双塔遗迹", "高原", "公路大战", "山岗", "工厂之战", "圣地之战", "小岛", "欧洲村庄", "大桥3C", "失落神庙", "疯狂思维空间", "十字角斗场", "高架桥", "平原", "火车站", "天空要塞", "山顶城堡", "炼油厂保卫战", "隧道对抗", "德国小镇", "边塞角斗场", "穿越之战", "小方块", "多边形", "红色警戒", "渡桥之战", "里约", "演练场", "高地角斗场", "辽源", "山城3C", "小桥之战", "寂静", "混乱城市", "摩天大楼", "废墟大战", "运动场", "地铁", "广场3C", "山谷", "潮汐", "城堡争夺", "2042", "约克郡", "动感区域" ];
let groupedWords = {};
let activeLength = 0;
let currentIndex = 0;
const dom = {
loader: document.getElementById('loader'),
app: document.getElementById('app'),
filters: document.getElementById('filters-container'),
prevBtn: document.getElementById('prev-btn'),
nextBtn: document.getElementById('next-btn'),
indicator: document.getElementById('position-indicator'),
display: document.getElementById('display-card')
};
const lengthIcons = {
3: 'segment',
2: 'drag_handle',
1: 'match_case'
};
function init() {
// Process Data
const wordCounts = {};
mapNames.forEach(name => {
const uniqueWordsInMap = new Set();
for (let i = 0; i < name.length; i++) {
for (let j = i + 1; j <= name.length; j++) {
uniqueWordsInMap.add(name.substring(i, j));
}
}
uniqueWordsInMap.forEach(word => {
wordCounts[word] = (wordCounts[word] || 0) + 1;
});
});
// Filter
let candidates = Object.entries(wordCounts).filter(([, count]) => count >= 2);
// Remove substrings if superstring exists with same count
const finalWords = candidates.filter(([word, count]) => {
return !candidates.some(([otherWord, otherCount]) =>
otherWord.length > word.length && otherWord.includes(word) && otherCount === count
);
});
// Sort
finalWords.sort(([wA, cA], [wB, cB]) => {
if (wB.length !== wA.length) return wB.length - wA.length;
if (cB !== cA) return cB - cA;
return wA.localeCompare(wB, "zh-Hans-CN");
});
// Group
finalWords.forEach(([word, count]) => {
const len = word.length;
if (!groupedWords[len]) groupedWords[len] = [];
groupedWords[len].push({ word, count });
});
// Setup UI
setupFilters();
// Initial Active State
const lengths = Object.keys(groupedWords).map(Number).sort((a, b) => b - a);
if (lengths.length > 0) {
activeLength = lengths[0];
updateDisplay(true); // Initial load, no fade animation
} else {
renderContent();
}
// Events
dom.prevBtn.addEventListener('click', () => navigate(-1));
dom.nextBtn.addEventListener('click', () => navigate(1));
document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft') navigate(-1);
if (e.key === 'ArrowRight') navigate(1);
});
}
function setupFilters() {
dom.filters.innerHTML = '';
const lengths = Object.keys(groupedWords).map(Number).sort((a, b) => b - a);
lengths.forEach(len => {
const btn = document.createElement('button');
btn.className = 'btn-icon';
btn.setAttribute('aria-label', `${len}个字`);
btn.dataset.len = len;
const icon = lengthIcons[len] || 'short_text';
btn.innerHTML = `<span class="material-symbols-rounded">${icon}</span>`;
btn.onclick = () => {
if (activeLength === len) return;
activeLength = len;
currentIndex = 0;
updateFiltersState();
updateDisplay();
};
dom.filters.appendChild(btn);
});
updateFiltersState();
}
function updateFiltersState() {
Array.from(dom.filters.children).forEach(btn => {
if (parseInt(btn.dataset.len) === activeLength) {
btn.classList.add('active');
} else {
btn.classList.remove('active');
}
});
}
function navigate(dir) {
const list = groupedWords[activeLength];
if (!list || list.length === 0) return;
let newIndex = currentIndex + dir;
if (newIndex < 0) newIndex = list.length - 1;
if (newIndex >= list.length) newIndex = 0;
currentIndex = newIndex;
updateDisplay();
}
// Handles the animation cycle
function updateDisplay(immediate = false) {
if (immediate) {
renderContent();
return;
}
dom.display.classList.add('fading');
setTimeout(() => {
renderContent();
dom.display.classList.remove('fading');
}, 200);
}
// Renders the HTML content based on current state
function renderContent() {
const list = groupedWords[activeLength];
if (!list || list.length === 0) {
dom.display.innerHTML = `
<div class="empty-state">
<span class="material-symbols-rounded" style="font-size: 48px; margin-bottom: 1rem; opacity: 0.5;">search_off</span>
<p>无数据</p>
</div>`;
dom.indicator.textContent = '0 / 0';
dom.prevBtn.disabled = true;
dom.nextBtn.disabled = true;
return;
}
const data = list[currentIndex];
// Map List HTML
const mapsHTML = mapNames
.filter(n => n.includes(data.word))
.sort((a, b) => a.localeCompare(b, 'zh-Hans-CN'))
.map(name => {
const highlighted = name.replace(
new RegExp(data.word, 'g'),
`<span class="highlight-word">${data.word}</span>`
);
return `<div class="map-item">${highlighted}</div>`;
}).join('');
dom.display.innerHTML = `
<div>
<div class="tag">出现 ${data.count} 次</div>
<h2 class="word-title">${data.word}</h2>
</div>
<div class="map-list-container">
<div class="map-list-header">相关地图</div>
<div class="map-list">
${mapsHTML}
</div>
</div>
`;
dom.indicator.textContent = `${currentIndex + 1} / ${list.length}`;
const hasMultiple = list.length > 1;
dom.prevBtn.disabled = !hasMultiple;
dom.nextBtn.disabled = !hasMultiple;
}
// Font Loading Strategy & Initialization
document.fonts.ready.then(() => {
init();
// Hide Loader
dom.loader.style.opacity = '0';
// Show App
document.body.classList.add('fonts-loaded');
setTimeout(() => {
dom.loader.style.display = 'none';
}, 500);
});
</script>
</body>
</html>