forked from blueeggs1125-art/bluekard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
664 lines (577 loc) · 22.9 KB
/
index.html
File metadata and controls
664 lines (577 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<link rel="icon" type="image/png" sizes="16x16" href="icon/16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="icon/32x32.png">
<link rel="icon" type="image/png" sizes="48x48" href="icon/48x48.png">
<link rel="icon" type="image/png" sizes="64x64" href="icon/64x64.png">
<link rel="icon" type="image/png" sizes="128x128" href="icon/128x128.png">
<link rel="icon" type="image/png" sizes="256x256" href="icon/256x256.png">
<link rel="icon" type="image/png" sizes="512x512" href="icon/512x512.png">
<link rel="apple-touch-icon" sizes="180x180" href="icon/180x180.png">
<link rel="manifest" href="site.webmanifest">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<title>FUCK 1939</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
padding: 10px;
background-color: #f5f5f5;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
h1 {
text-align: center;
margin-bottom: 20px;
color: #333;
font-size: 24px;
}
.selector-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
select, input {
width: 100%;
padding: 10px;
border-radius: 5px;
border: 1px solid #ddd;
background-color: white;
font-size: 16px;
margin-bottom: 10px;
}
.image-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
gap: 15px;
margin-top: 10px;
}
.image-item {
position: relative;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
background-color: white;
aspect-ratio: 2/3;
}
.image-item img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
-webkit-touch-callout: default; /* 允许iOS上的长按菜单 */
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.image-item .image-name {
padding: 5px;
font-size: 11px;
text-align: center;
background-color: rgba(0,0,0,0.8);
color: white;
position: absolute;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.no-images {
text-align: center;
padding: 40px 20px;
color: #999;
font-style: italic;
grid-column: 1 / -1;
}
.loading {
text-align: center;
padding: 40px 20px;
color: #666;
grid-column: 1 / -1;
}
/* 添加导航链接样式 */
.nav-link {
display: block;
text-align: center;
margin: 15px 0;
color: #1e90ff;
text-decoration: none;
font-weight: bold;
}
.nav-link:hover {
text-decoration: underline;
}
@media (max-width: 768px) {
.container {
padding: 0 10px;
}
.image-container {
grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
gap: 8px;
}
h1 {
font-size: 20px;
}
}
@media (max-width: 480px) {
.image-container {
grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
gap: 5px;
}
.image-item .image-name {
font-size: 8px;
padding: 2px;
}
}
</style>
</head>
<body>
<style>
/* 统一的页面载入动画 */
@keyframes pageSlideIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* 应用到所有页面容器 */
.container {
animation: pageSlideIn 0.4s ease-out forwards;
}
/* 为已有动画的页面调整动画 */
.content {
animation: pageSlideIn 0.4s ease-out forwards;
}
/* 视频列表动画 */
.video-list {
animation: pageSlideIn 0.4s ease-out forwards;
}
/* 音效容器动画 */
#sound-display {
animation: pageSlideIn 0.4s ease-out forwards;
}
/* 图片容器动画 */
#image-display {
animation: pageSlideIn 0.4s ease-out forwards;
}
/* 导航栏动画 */
.bottom-nav {
animation: pageSlideIn 0.4s ease-out 0.1s forwards;
animation-fill-mode: both;
}
/* 初始状态设置 */
.container,
.content,
.video-list,
#sound-display,
#image-display,
.bottom-nav {
opacity: 0;
}
/* 延迟显示内容,避免闪烁 */
@media (prefers-reduced-motion: reduce) {
.container,
.content,
.video-list,
#sound-display,
#image-display,
.bottom-nav {
animation: none;
opacity: 1;
}
}
</style>
<style>
/* 在现有样式基础上添加 */
.container {
padding-bottom: 60px; /* 为底部导航栏留出空间 */
}
</style>
<style>
/* 底部按钮样式 */
.bottom-button-container {
position: fixed;
bottom: 60px;
left: 0;
right: 0;
text-align: center;
padding: 10px 0;
z-index: 1000;
}
.bottom-button {
display: inline-block;
padding: 10px 20px;
background-color: #1e90ff;
color: white;
text-decoration: none;
border-radius: 5px;
font-weight: bold;
transition: background-color 0.3s;
}
.bottom-button:hover {
background-color: #0066cc;
}
</style>
<div class="bottom-button-container">
<a href="https://blueeggs1125-art.github.io/im/" class="bottom-button" target="_blank">卡图原画(非海报)</a>
</div>
<!-- 在 </body> 标签前添加 -->
<div style="position: fixed; bottom: 0; left: 0; right: 0; background-color: #fff; border-top: 1px solid #ddd; display: flex; justify-content: space-around; padding: 10px 0; z-index: 1000; font-size: 14px;">
<a href="index.html" style="text-decoration: none; color: #1e90ff; text-align: center;">卡图</a>
<a href="image2.html" style="text-decoration: none; color: #1e90ff; text-align: center;">其他素材</a>
<a href="suck.html" style="text-decoration: none; color: #1e90ff; text-align: center;">音效库</a>
<a href="zaza.html" style="text-decoration: none; color: #1e90ff; text-align: center;">加载动画</a>
<a href="team.html" style="text-decoration: none; color: #1e90ff; text-align: center;">关于</a>
</div>
<div class="container">
<h1>KARDS素材库</h1>
<!-- 添加跳转到音效页面的链接 -->
<div class="selector-group">
<label for="search-input">搜索图片:</label>
<input type="text" id="search-input" placeholder="输入关键词搜索图片...">
</div>
<div class="selector-group">
<label for="country-select">选择国家/类型:</label>
<select id="country-select">
<option value="">请选择...</option>
<option value="苏联">苏联</option>
<option value="美国">美国</option>
<option value="德国">德国</option>
<option value="日本">日本</option>
<option value="英国">英国</option>
<option value="波兰">波兰</option>
<option value="法国">法国</option>
<option value="意大利">意大利</option>
<option value="芬兰">芬兰</option>
<option value="总部">总部</option>
<option value="卡背">卡背</option>
</select>
</div>
<div class="selector-group" id="subtype-group" style="display: none;">
<label for="subtype-select">选择卡牌类型:</label>
<select id="subtype-select">
<option value="">请选择...</option>
</select>
</div>
<div id="image-display">
<div class="no-images">请先选择国家/类型或搜索关键词</div>
</div>
</div>
<script src="js/image.js"></script>
<script>
// 添加一个新函数用于处理包含中文的图片路径
function encodeImagePath(path) {
// 将路径中的每个部分进行编码,但保持分隔符不变
return path.split('/').map(part => encodeURIComponent(part)).join('/');
}
// 根据关键词搜索图片
function searchImagesByKeyword(keyword) {
return fetch('data/newimages.json')
.then(response => {
if (!response.ok) {
throw new Error('newimages.json 网络响应错误');
}
return response.json();
})
.then(imagesData => {
const results = [];
const searchKeyword = keyword.trim().toLowerCase();
const addedPaths = new Set(); // 用于避免重复添加
// 遍历 newimages.json 中的图片数据
for (const country in imagesData) {
if (!imagesData.hasOwnProperty(country)) continue;
const countryData = imagesData[country];
// 如果国家数据是数组格式(总部、卡背等没有子类型)
if (Array.isArray(countryData)) {
countryData.forEach(imagePath => {
const fileName = imagePath.split('/').pop();
// 只检查文件名是否匹配关键词(不区分大小写)
if (fileName.toLowerCase().includes(searchKeyword)) {
// 避免重复添加
if (!addedPaths.has(imagePath)) {
addedPaths.add(imagePath);
results.push({
path: imagePath,
name: fileName,
description: ''
});
}
}
});
}
// 如果国家数据是对象格式(有子类型:金卡、银卡等)
else {
for (const subtype in countryData) {
if (!countryData.hasOwnProperty(subtype)) continue;
countryData[subtype].forEach(imagePath => {
const fileName = imagePath.split('/').pop();
// 只检查文件名是否匹配关键词(不区分大小写)
if (fileName.toLowerCase().includes(searchKeyword)) {
// 避免重复添加
if (!addedPaths.has(imagePath)) {
addedPaths.add(imagePath);
results.push({
path: imagePath,
name: fileName,
description: ''
});
}
}
});
}
}
}
return results;
})
.catch(error => {
console.error('搜索图片失败:', error);
return [];
});
}
const countries = {
'苏联': { name: '苏联', hasSubtypes: true },
'美国': { name: '美国', hasSubtypes: true },
'德国': { name: '德国', hasSubtypes: true },
'日本': { name: '日本', hasSubtypes: true },
'英国': { name: '英国', hasSubtypes: true },
'波兰': { name: '波兰', hasSubtypes: true },
'法国': { name: '法国', hasSubtypes: true },
'意大利': { name: '意大利', hasSubtypes: true },
'芬兰': { name: '芬兰', hasSubtypes: true },
'总部': { name: '总部', hasSubtypes: false },
'卡背': { name: '卡背', hasSubtypes: false }
};
const subtypes = {
'金卡': '金卡',
'银卡': '银卡',
'铜卡': '铜卡',
'铁卡': '铁卡'
};
const noGoldCountries = ['波兰', '法国', '意大利', '芬兰'];
const countrySelect = document.getElementById('country-select');
const subtypeGroup = document.getElementById('subtype-group');
const subtypeSelect = document.getElementById('subtype-select');
const imageDisplay = document.getElementById('image-display');
const searchInput = document.getElementById('search-input');
// 添加搜索功能
searchInput.addEventListener('input', function() {
const keyword = this.value.trim();
if (keyword.length > 0) {
searchImages(keyword);
} else if (countrySelect.value) {
// 如果搜索框为空但已选择国家,则显示该国家的图片
if (countries[countrySelect.value].hasSubtypes && subtypeSelect.value) {
displayImages(countrySelect.value, subtypeSelect.value);
} else if (!countries[countrySelect.value].hasSubtypes) {
displayImages(countrySelect.value);
} else {
imageDisplay.innerHTML = '<div class="no-images">请选择卡牌类型</div>';
}
} else {
imageDisplay.innerHTML = '<div class="no-images">请先选择国家/类型或搜索关键词</div>';
}
});
countrySelect.addEventListener('change', function() {
const country = this.value;
if (!country) {
subtypeGroup.style.display = 'none';
imageDisplay.innerHTML = '<div class="no-images">请先选择国家/类型</div>';
return;
}
const countryConfig = countries[country];
if (countryConfig.hasSubtypes) {
subtypeGroup.style.display = 'block';
updateSubtypeOptions(country);
imageDisplay.innerHTML = '<div class="no-images">请选择卡牌类型</div>';
} else {
subtypeGroup.style.display = 'none';
displayImages(country);
}
});
subtypeSelect.addEventListener('change', function() {
const country = countrySelect.value;
const subtype = this.value;
if (country && subtype) {
displayImages(country, subtype);
} else {
imageDisplay.innerHTML = '<div class="no-images">请选择卡牌类型</div>';
}
});
function updateSubtypeOptions(country) {
subtypeSelect.innerHTML = '<option value="">请选择...</option>';
for (const [key, name] of Object.entries(subtypes)) {
if (key === '金卡' && noGoldCountries.includes(country)) {
continue;
}
const option = document.createElement('option');
option.value = key;
option.textContent = name;
subtypeSelect.appendChild(option);
}
}
// 显示特定国家和类型的图片
async function displayImages(country, subtype = null) {
imageDisplay.innerHTML = '<div class="loading">加载中...</div>';
try {
const response = await fetch('data/newimages.json');
if (!response.ok) {
throw new Error('newimages.json 网络响应错误');
}
const imagesData = await response.json();
let filteredImages = [];
// 根据国家和子类型筛选图片
if (imagesData[country]) {
if (countries[country].hasSubtypes && subtype && imagesData[country][subtype]) {
// 有子类型的情况
filteredImages = imagesData[country][subtype];
} else if (!countries[country].hasSubtypes) {
// 没有子类型的情况(总部、卡背)
filteredImages = imagesData[country];
}
}
if (filteredImages.length === 0) {
imageDisplay.innerHTML = '<div class="no-images">暂无图片</div>';
return;
}
renderImages(filteredImages);
} catch (error) {
console.error('加载图片出错:', error);
imageDisplay.innerHTML = '<div class="no-images">加载图片失败</div>';
}
}
// 搜索图片功能
async function searchImages(keyword) {
imageDisplay.innerHTML = '<div class="loading">搜索中...</div>';
try {
const searchResults = await searchImagesByKeyword(keyword);
if (searchResults.length === 0) {
imageDisplay.innerHTML = '<div class="no-images">未找到匹配的图片</div>';
return;
}
renderImages(searchResults);
} catch (error) {
console.error('搜索图片出错:', error);
imageDisplay.innerHTML = '<div class="no-images">搜索图片失败</div>';
}
}
// 渲染图片列表
function renderImages(images) {
let html = '<div class="image-container">';
images.forEach(image => {
// 处理搜索结果和普通图片路径的不同
const imagePath = typeof image === 'object' ? image.path : image;
// 对整个路径进行编码以支持中文
const encodedImagePath = encodeImagePath(imagePath);
const fileName = imagePath.split('/').pop();
const displayName = typeof image === 'object' ? (image.name || fileName) : fileName;
// 对文件名进行编码用于下载
const encodedFileName = encodeURIComponent(fileName);
html += `
<div class="image-item">
<img src="${encodedImagePath}" alt="${displayName}"
data-url="${encodedImagePath}"
data-filename="${encodedFileName}"
onload="this.parentNode.classList.add('loaded')">
</div>
`;
});
html += '</div>';
imageDisplay.innerHTML = html;
// 为所有图片添加触摸事件
document.querySelectorAll('.image-item img').forEach(img => {
new ImageTouchHandler(img);
});
}
// 图片触摸处理类
class ImageTouchHandler {
constructor(element) {
this.element = element;
this.touchStartTime = 0;
this.touchTimer = null;
this.touchHandled = false;
this.init();
}
init() {
// 添加触摸事件监听器
this.element.addEventListener('touchstart', (e) => this.handleTouchStart(e), { passive: false });
this.element.addEventListener('touchend', (e) => this.handleTouchEnd(e), { passive: false });
this.element.addEventListener('touchmove', (e) => this.handleTouchMove(e), { passive: false });
this.element.addEventListener('contextmenu', (e) => this.handleContextMenu(e));
}
handleTouchStart(event) {
this.touchStartTime = Date.now();
this.touchHandled = false;
clearTimeout(this.touchTimer);
// 长按800ms后触发下载
this.touchTimer = setTimeout(() => {
if (!this.touchHandled) {
this.downloadImage();
this.touchHandled = true;
}
}, 800);
// 阻止默认行为和事件冒泡
// 注意:不要完全阻止,否则可能影响长按菜单
// event.preventDefault();
// event.stopPropagation();
}
handleTouchMove(event) {
// 如果用户移动手指,取消长按下载
clearTimeout(this.touchTimer);
this.touchHandled = true;
}
handleTouchEnd(event) {
// 如果用户提前结束触摸,取消长按下载
clearTimeout(this.touchTimer);
this.touchHandled = true;
}
handleContextMenu(event) {
// 右键菜单触发下载
event.preventDefault();
this.downloadImage();
}
downloadImage() {
const url = this.element.dataset.url;
const filename = decodeURIComponent(this.element.dataset.filename);
const link = document.createElement('a');
link.href = url;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
// 为了兼容性,也保留全局函数
function downloadImage(event, url, filename) {
event.preventDefault();
event.stopPropagation();
const link = document.createElement('a');
link.href = url;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
</script>
</body>
</html>