-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMath.html
More file actions
435 lines (381 loc) · 16.7 KB
/
Copy pathMath.html
File metadata and controls
435 lines (381 loc) · 16.7 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>数学题单 - XCPC-Math-Finder</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<style>
body {
margin: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f4f7f6;
color: #333;
scroll-behavior: smooth;
min-height: 100vh;
position: relative;
}
body::before {
content: "";
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('BG.png');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
filter: brightness(0.75);
z-index: -1;
}
header {
width: 100%;
background-color: #f39c12;
color: white;
padding: 10px 40px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
position: fixed;
top: 0;
z-index: 1000;
}
.header-left { display: flex; align-items: baseline; gap: 15px; }
.header-left h1 { margin: 0; font-size: 1.8em; letter-spacing: 1px; }
.header-left .author { font-size: 1em; opacity: 0.9; }
.header-right-nav { display: flex; align-items: center; }
.back-btn {
background-color: rgba(255, 255, 255, 0.2);
color: white;
text-decoration: none;
padding: 8px 18px;
border-radius: 50px;
font-weight: bold;
transition: all 0.3s ease;
border: 1px solid rgba(255, 255, 255, 0.4);
font-size: 0.9em;
display: flex;
align-items: center;
gap: 6px;
}
.back-btn:hover {
background-color: rgba(255, 255, 255, 0.35);
transform: scale(1.05);
}
.toolbar {
max-width: 1100px;
width: 100%;
margin: 90px auto 10px auto;
padding: 0 20px;
box-sizing: border-box;
display: flex;
justify-content: flex-start;
}
.search-box {
background-color: rgba(255, 255, 255, 0.65);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.4);
border-radius: 50px;
padding: 10px 20px;
display: flex;
align-items: center;
gap: 10px;
width: 350px;
box-shadow: 0 4px 15px rgba(0,0,0,0.05);
transition: all 0.3s ease;
}
.search-box:focus-within {
background-color: rgba(255, 255, 255, 0.85);
box-shadow: 0 6px 20px rgba(0,0,0,0.1);
transform: translateY(-2px);
}
.search-box i { color: #7f8c8d; }
.search-box input {
border: none;
background: transparent;
outline: none;
width: 100%;
font-size: 1em;
color: #2c3e50;
font-weight: 500;
}
.search-box input::placeholder { color: #95a5a6; }
.floating-nav {
position: fixed;
bottom: 40px;
right: 40px;
display: flex;
flex-direction: column;
gap: 12px;
z-index: 1000;
}
.btn-jump {
background-color: rgba(52, 152, 219, 0.7);
backdrop-filter: blur(5px);
color: white;
text-decoration: none;
padding: 10px 20px;
border-radius: 50px;
font-weight: bold;
font-size: 0.9em;
box-shadow: 0 8px 20px rgba(0,0,0,0.15);
transition: all 0.3s;
text-align: center;
border: 1px solid rgba(255,255,255,0.2);
}
.btn-jump:hover {
background-color: rgba(41, 128, 185, 0.95);
transform: translateX(-5px);
}
.container {
max-width: 1100px;
width: 100%;
margin: 0 auto;
padding: 10px 20px 100px 20px;
box-sizing: border-box;
}
.category-section { margin-bottom: 50px; }
.category-title {
color: #fff;
font-size: 2em;
margin-bottom: 20px;
text-shadow: 0 2px 4px rgba(0,0,0,0.4);
display: flex;
align-items: center;
gap: 12px;
padding-top: 20px;
}
.category-title i { color: #f39c12; }
.section-divider { border: 0; height: 3px; background: linear-gradient(to right, #f39c12, transparent); margin-bottom: 25px; }
table {
width: 100%;
border-collapse: collapse;
background-color: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(10px);
box-shadow: 0 10px 25px rgba(0,0,0,0.06);
border-radius: 12px;
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.4);
}
th, td { padding: 14px 15px; text-align: left; border-bottom: 1px solid rgba(238, 238, 238, 0.5); }
th { background-color: rgba(44, 62, 80, 0.9); color: white; font-weight: 600; font-size: 0.95em; }
td { color: #2c3e50; font-weight: 500; font-size: 0.95em; transition: opacity 0.3s; }
tr:hover td { background-color: rgba(255, 255, 255, 0.5); }
.subcat-header {
background-color: rgba(236, 240, 241, 0.85) !important;
color: #2980b9 !important;
font-weight: bold !important;
font-size: 1.05em !important;
text-align: center;
}
.badge { padding: 4px 10px; border-radius: 6px; font-size: 0.85em; font-weight: bold; color: white; display: inline-block; text-align: center; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.badge-cf { background-color: #2980b9; }
.badge-qoj { background-color: #e67e22; }
.diff-easy { background-color: #27ae60; }
.diff-medium { background-color: #f39c12; }
.diff-hard { background-color: #c0392b; }
a.link-btn { color: #2980b9; text-decoration: none; font-weight: bold; }
a.link-btn:hover { text-decoration: underline; color: #1f618d; }
input[type="checkbox"] { transform: scale(1.4); cursor: pointer; }
tr.done-row td { opacity: 0.5; }
tr.done-row td:first-child { opacity: 1; }
.empty-state { text-align: center; padding: 30px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.5); font-weight: bold; font-size: 1.1em; background: rgba(0,0,0,0.2); border-radius: 10px; }
/* 移动端自适应 */
@media (max-width: 768px) {
header { padding: 10px 15px; }
.header-left h1 { font-size: 1.2em; }
.header-left .author { display: none; }
.header-right-nav { font-size: 1.2em; gap: 15px; }
.back-btn { padding: 6px 12px; font-size: 0.8em; }
.toolbar { margin-top: 70px; padding: 0 10px; }
.search-box { width: 100%; }
.container { padding-left: 10px; padding-right: 10px; }
table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
th, td { padding: 12px 10px; }
.floating-nav { bottom: 20px; right: 15px; gap: 10px; }
.btn-jump { padding: 8px 16px; font-size: 0.85em; }
}
</style>
</head>
<body>
<header>
<div class="header-left">
<h1>XCPC-Math-Finder</h1>
<span class="author">🧮 专项数学训练</span>
</div>
<div class="header-right-nav">
<a href="index.html" class="back-btn"><i class="fa-solid fa-house"></i> 返回主页</a>
</div>
</header>
<div class="toolbar">
<div class="search-box">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="text" id="search-input" placeholder="搜索细分小类、比赛名称或题号..." oninput="handleSearch()">
</div>
</div>
<div class="floating-nav" id="nav-container">
</div>
<div class="container" id="main-container">
</div>
<script>
const CATEGORIES = ["计数问题", "纯数论", "线性代数", "概率与期望"];
const DIFF_WEIGHT = { "Easy": 1, "Medium": 2, "Hard": 3 };
let globalMathData = [];
let doneMap = JSON.parse(localStorage.getItem('math_done_records')) || {};
// 新增状态:默认隐藏细分小类
let hideSubtags = true;
const navContainer = document.getElementById('nav-container');
const mainContainer = document.getElementById('main-container');
// 初始化导航锚点与控制开关
function initNav() {
let html = CATEGORIES.map((cat, index) =>
`<a href="#cat-${index}" class="btn-jump"><i class="fa-solid fa-tag"></i> ${cat}</a>`
).join('');
// 挂载显示/隐藏切换按钮 (初始状态根据hideSubtags设定)
const icon = hideSubtags ? "fa-eye-slash" : "fa-eye";
const text = hideSubtags ? "显示细分Tag" : "隐藏细分Tag";
html += `<a href="#" class="btn-jump" style="background-color: rgba(149, 165, 166, 0.9);" onclick="toggleSubtags(event)" id="btn-toggle-sub"><i class="fa-solid ${icon}"></i> ${text}</a>`;
navContainer.innerHTML = html;
}
// 切换函数
function toggleSubtags(e) {
e.preventDefault();
hideSubtags = !hideSubtags;
const btn = document.getElementById('btn-toggle-sub');
if (hideSubtags) {
btn.innerHTML = '<i class="fa-solid fa-eye-slash"></i> 显示细分Tag';
} else {
btn.innerHTML = '<i class="fa-solid fa-eye"></i> 隐藏细分Tag';
}
// 保持搜索词的情况下重新渲染
handleSearch();
}
function getPlatformBadge(platform) {
if (platform === 'Codeforces') return '<span class="badge badge-cf">Codeforces</span>';
if (platform === 'QOJ') return '<span class="badge badge-qoj">QOJ</span>';
return `<span class="badge" style="background:#7f8c8d;">${platform}</span>`;
}
function getDiffBadge(diff) {
let cls = 'diff-easy';
if (diff === 'Medium') cls = 'diff-medium';
if (diff === 'Hard') cls = 'diff-hard';
return `<span class="badge ${cls}">${diff}</span>`;
}
function toggleMathDone(id, currentState) {
doneMap[id] = !currentState;
localStorage.setItem('math_done_records', JSON.stringify(doneMap));
renderMathView(document.getElementById('search-input').value.trim());
}
function handleSearch() {
const keyword = document.getElementById('search-input').value.trim();
renderMathView(keyword);
}
function renderMathView(filterKeyword = '') {
mainContainer.innerHTML = '';
const keyword = filterKeyword.toLowerCase();
// 1. 过滤数据
let filteredData = globalMathData;
if (keyword) {
filteredData = globalMathData.filter(item => {
const matchName = (item.contest_name || '').toLowerCase().includes(keyword);
const matchSub = (item.subcategory || '').toLowerCase().includes(keyword);
const matchId = (item.problem_id || '').toLowerCase().includes(keyword);
return matchName || matchSub || matchId;
});
}
// 2. 按四大类循环渲染
CATEGORIES.forEach((cat, index) => {
const section = document.createElement('div');
section.className = 'category-section';
section.id = `cat-${index}`;
section.innerHTML = `
<h2 class="category-title"><i class="fa-solid fa-cube"></i> ${cat}</h2>
<hr class="section-divider">
`;
const catData = filteredData.filter(item => item.category === cat);
if (catData.length === 0) {
section.innerHTML += `<div class="empty-state">暂无符合条件的题目</div>`;
mainContainer.appendChild(section);
return;
}
// 3. 构建聚合逻辑:如果 hideSubtags 为真,则不按小类拆分
const renderGroups = {};
if (hideSubtags) {
renderGroups['ALL'] = catData;
} else {
catData.forEach(item => {
const sub = item.subcategory || '其他';
if (!renderGroups[sub]) renderGroups[sub] = [];
renderGroups[sub].push(item);
});
}
// 4. 构建表格
const table = document.createElement('table');
let tbodyHTML = `
<thead>
<tr>
<th width="60px">状态</th>
<th width="100px">难度</th>
<th width="100px">平台</th>
<th>比赛名称 & 题号</th>
<th width="120px">操作</th>
</tr>
</thead>
<tbody>
`;
// 遍历渲染组
for (const [subcat, problems] of Object.entries(renderGroups)) {
// 如果处于显示细分状态,渲染组头
if (!hideSubtags) {
tbodyHTML += `<tr><td colspan="5" class="subcat-header">🏷️ ${subcat}</td></tr>`;
}
// 排序核心逻辑依然生效:未做在前(0),已做沉底(1)。同状态按照 Easy->Medium->Hard 排序
problems.sort((a, b) => {
const doneA = doneMap[a.id] ? 1 : 0;
const doneB = doneMap[b.id] ? 1 : 0;
if (doneA !== doneB) return doneA - doneB;
const weightA = DIFF_WEIGHT[a.difficulty] || 0;
const weightB = DIFF_WEIGHT[b.difficulty] || 0;
return weightA - weightB;
});
// 生成题目行
problems.forEach(p => {
const isDone = doneMap[p.id] || false;
const rowClass = isDone ? 'done-row' : '';
tbodyHTML += `
<tr class="${rowClass}">
<td>
<input type="checkbox" ${isDone ? 'checked' : ''}
onchange="toggleMathDone('${p.id}', ${isDone})">
</td>
<td>${getDiffBadge(p.difficulty)}</td>
<td>${getPlatformBadge(p.platform)}</td>
<td><strong>${p.contest_name}</strong> - Problem ${p.problem_id}</td>
<td><a href="${p.contest_url}" target="_blank" class="link-btn">去切题 🚀</a></td>
</tr>
`;
});
}
tbodyHTML += `</tbody>`;
table.innerHTML = tbodyHTML;
section.appendChild(table);
mainContainer.appendChild(section);
});
}
initNav();
fetch('math_problems.json')
.then(res => res.json())
.then(data => {
globalMathData = data;
renderMathView();
})
.catch(err => {
console.error("加载数学题库失败", err);
mainContainer.innerHTML = `<div class="empty-state" style="color:#e74c3c; background:rgba(255,255,255,0.8);">⚠️ 无法读取题库数据。请确保已通过 Python 脚本录入了题目,并在本地 Server 环境下运行。</div>`;
});
</script>
</body>
</html>