-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbasic.html
More file actions
825 lines (756 loc) · 26.7 KB
/
Copy pathbasic.html
File metadata and controls
825 lines (756 loc) · 26.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
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>CSES课程表编辑器</title>
<script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/js-yaml/4.1.0/js-yaml.min.js" type="application/javascript"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/Sortable/1.14.0/Sortable.min.js" type="application/javascript"></script>
<!-- <script type="module" src="https://unpkg.com/@fluentui/web-components"></script> -->
<style>
:root {
--bg-color: #1e1e1e;
--sidebar-bg: #252526;
--border-color: #3c3c3c;
--text-color: #cccccc;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
sans-serif;
background: var(--bg-color);
color: var(--text-color);
height: 100vh;
display: flex;
flex-direction: column;
}
/* 顶部菜单栏 */
.menu-bar {
height: 30px;
background: var(--sidebar-bg);
display: flex;
align-items: center;
padding: 0 1rem;
border-bottom: 1px solid var(--border-color);
}
.menu-bar button {
background: none;
border: none;
color: var(--text-color);
padding: 4px 8px;
cursor: pointer;
}
.menu-bar button:hover {
background: #2a2d2e;
}
/* 主容器 */
.container {
display: flex;
flex: 1;
overflow: hidden;
}
/* 左侧功能栏 */
.activity-bar {
width: 48px;
background: var(--sidebar-bg);
border-right: 1px solid var(--border-color);
display: flex;
flex-direction: column;
align-items: center;
padding-top: 1rem;
}
.activity-item {
width: 32px;
height: 32px;
margin-bottom: 1rem;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
font-size: 20px;
}
.activity-item.active {
background: #37373d;
}
/* 资源管理器 */
.explorer {
width: 250px;
background: var(--sidebar-bg);
border-right: 1px solid var(--border-color);
overflow-y: auto;
}
.explorer-item {
padding: 8px 16px;
cursor: pointer;
}
.explorer-item:hover {
background: #2a2d2e;
}
.explorer-item.active {
background: #37373d;
}
/* 编辑区域 */
.editor-area {
flex: 1;
padding: 1rem;
overflow-y: auto;
}
/* 课程卡片 */
.class-card {
background: #2d2d2d;
padding: 1rem;
margin-bottom: 8px;
border-radius: 4px;
cursor: move;
}
.time-input {
background: #3c3c3c;
border: 1px solid var(--border-color);
color: var(--text-color);
padding: 4px;
margin: 0 4px;
}
/* 拖拽区域 */
#class-list {
min-height: 300px;
padding: 1rem;
border: 1px solid var(--border-color);
border-radius: 4px;
}
/* YAML编辑器 */
#yaml-editor {
width: 100%;
height: 500px;
background: var(--bg-color);
color: var(--text-color);
border: 1px solid var(--border-color);
padding: 1rem;
font-family: monospace;
}
button,
input,
select,
textarea {
background: var(--bg-color);
border: 1px solid var(--border-color);
color: var(--text-color);
padding: 4px 8px;
border-radius: 4px;
font-size: 14px;
}
button:hover,
input:hover,
select:hover,
textarea:hover {
border-color: #007acc;
}
button:active,
input:active,
select:active,
textarea:active {
border-color: #005a9e;
}
button:focus,
input:focus,
select:focus,
textarea:focus {
outline: none;
border-color: #007acc;
box-shadow: 0 0 0 1px #007acc;
}
button {
cursor: pointer;
}
button:disabled {
cursor: not-allowed;
opacity: 0.6;
}
#subject-form {
display: flex;
flex-direction: column;
}
#subject-form input {
width: 100%;
padding: 0.5rem;
font-size: 1rem;
margin: 0.5rem 0;
}
</style>
<link href="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/bootstrap-icons/1.8.1/font/bootstrap-icons.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="menu-bar">
<span>CSES Editor </span>
<button onclick="importFile()">导入</button>
<button onclick="exportFile()">导出</button>
<button onclick="clearData()">清空</button>
<button onclick="keyHelp()">快捷键</button>
<button onclick="about()">关于</button>
<button onclick="window.location = './index.html'">FluentUI</button>
<input type="file" id="file-input" hidden accept=".yaml,.yml" />
</div>
<div class="container">
<div class="activity-bar">
<div class="activity-item active" data-view="schedule">
<i class="bi bi-calendar"></i>
</div>
<div class="activity-item" data-view="subject">
<i class="bi bi-journal-bookmark"></i>
</div>
<div class="activity-item" data-view="source">
<i class="bi bi-file-earmark-text"></i>
</div>
</div>
<div class="explorer">
<div id="schedule-list"></div>
<div id="subject-list" style="display: none"></div>
<div
id="add-schedule-btn"
class="explorer-item"
onclick="addNewClass()"
>
+ 添加课程
</div>
<div
id="add-subject-btn"
class="explorer-item"
style="display: none"
onclick="addNewSubject()"
>
+ 添加科目
</div>
</div>
<div class="editor-area">
<div id="schedule-editor" style="display: none">
<h2>课程计划编辑</h2><br>
<div class="schedule-header">
课程模式: <select id="week-mode" onchange="updateSchedule()">
<option value="odd">单周</option>
<option value="even">双周</option>
<option value="all">通用</option>
</select><br><br>
启用星期: <select id="day-mode" onchange="updateSchedule()">
<option value="mon">星期一</option>
<option value="tue">星期二</option>
<option value="wed">星期三</option>
<option value="thu">星期四</option>
<option value="fri">星期五</option>
<option value="sat">星期六</option>
<option value="sun">星期日</option>
</select>
</div><br>
<div id="class-list"></div>
<button onclick="addNewClassTime()" style="margin-top: 1rem">
+ 添加课时
</button>
<button onclick="copySchdule()" style="margin-top: 1rem">
复制副本
</button>
</div>
<div id="source-editor" style="display: none">
<h3>YAML预览</h3>
<textarea id="yaml-editor"></textarea>
</div>
<div id="subject-editor" style="display: none">
<h2>科目信息管理</h2><br>
<div id="subject-form">
科目名称:<input type="text" id="subject-name" placeholder="科目名称" />
科目简写:<input type="text" id="subject-simple" placeholder="简称" />
任课教师:<input type="text" id="subject-teacher" placeholder="任课教师" />
教学教室:<input type="text" id="subject-room" placeholder="教室" />
<br>
<button
onclick="saveSubject()"
style="padding: 0.5rem; font-size: 1rem"
>
保存
</button>
</div>
</div>
</div>
</div>
<script>
let currentData = {
version: 1,
subjects: [],
schedules: [],
};
let currentScheduleIndex = -1;
// 初始化
function init() {
loadFromStorage();
initActivityBar();
initSchedules();
initSubjects();
initDragDrop();
}
// 从localStorage加载数据
function loadFromStorage() {
const saved = localStorage.getItem("csesData");
if (saved) currentData = JSON.parse(saved);
}
// 初始化功能切换栏
function initActivityBar() {
document.querySelectorAll(".activity-item").forEach((item) => {
item.addEventListener("click", () => {
document
.querySelectorAll(".activity-item")
.forEach((i) => i.classList.remove("active"));
item.classList.add("active");
showView(item.dataset.view);
});
});
}
// 显示对应视图
function showView(view) {
document.querySelectorAll(".editor-area > div").forEach((div) => {
div.style.display = "none";
});
document.getElementsByClassName("explorer")[0].style.display = "block";
document.getElementById(`${view}-editor`).style.display = "none";
if (view === "schedule") {
document.getElementById("schedule-list").style.display = "block";
document.getElementById("subject-list").style.display = "none";
refreshScheduleList();
} else if (view === "source") {
document.getElementById("schedule-list").style.display = "none";
document.getElementById("subject-list").style.display = "none";
document.getElementsByClassName("explorer")[0].style.display = "none";
document.getElementById(`${view}-editor`).style.display = "block";
document.getElementById("yaml-editor").value =
jsyaml.dump(currentData);
} else if (view === "subject") {
document.getElementById("schedule-list").style.display = "none";
document.getElementById("subject-list").style.display = "block";
refreshSubjectList();
}
}
// 初始化计划列表
function initSchedules() {
const container = document.getElementById("schedule-list");
container.innerHTML = "";
currentData.schedules.forEach((schedule, index) => {
const div = document.createElement("div");
div.className = "explorer-item";
const [weekMode, dayMode] = schedule.name.split("_");
div.textContent = (weekMap[weekMode] && dayMap[dayMode]) ? weekMap[weekMode]+"_"+dayMap[dayMode] : `无规则计划 ${index + 1}`;
div.addEventListener("click", () => {
loadSchedule(index);
document.querySelectorAll(".explorer-item").forEach((item) => item.classList.remove("active"));
div.classList.add("active");
});
div.addEventListener("contextmenu", (e) => {
e.preventDefault();
if (
confirm(
`确定要删除计划 ${
(weekMap[weekMode] && dayMap[dayMode]) ? weekMap[weekMode]+"_"+dayMap[dayMode] : `无规则计划 ${index + 1}`
} 吗?`
)
) {
currentData.schedules.splice(index, 1);
saveSchedule();
refreshScheduleList();
}
});
container.appendChild(div);
});
}
// 初始化科目列表
function initSubjects() {
const container = document.getElementById("subject-list");
container.innerHTML = "";
currentData.subjects.forEach((subject, index) => {
const div = document.createElement("div");
div.className = "explorer-item";
div.textContent = subject.name;
div.addEventListener("click", () => loadSubject(index));
div.addEventListener("contextmenu", (e) => {
e.preventDefault();
if (confirm(`确定要删除科目 ${subject.name} 吗?`)) {
currentData.subjects.splice(index, 1);
saveSchedule();
refreshSubjectList();
}
});
container.appendChild(div);
});
}
// 初始化科目列表
function initSubjects() {
const container = document.getElementById("subject-list");
container.innerHTML = "";
if (currentData.subjects.length === 0) {
currentData.subjects = [
{ name: "语文", simple: "语", teacher: "周老师", room: "106" },
{ name: "数学", simple: "数", teacher: "张老师", room: "101" },
{ name: "英语", simple: "英", teacher: "李老师", room: "102" },
{ name: "物理", simple: "物", teacher: "王老师", room: "103" },
{ name: "化学", simple: "化", teacher: "赵老师", room: "104" },
{ name: "生物", simple: "生", teacher: "孙老师", room: "105" },
{ name: "历史", simple: "历", teacher: "吴老师", room: "107" },
{ name: "地理", simple: "地", teacher: "郑老师", room: "108" },
{ name: "政治", simple: "政", teacher: "冯老师", room: "109" },
{ name: "信息技术", simple: "信", teacher: "陈老师", room: "110" },
{ name: "通用技术", simple: "通", teacher: "褚老师", room: "111" },
{ name: "班会", simple: "班", teacher: "卫老师", room: "112" },
];
saveSchedule();
}
currentData.subjects.forEach((subject, index) => {
const div = document.createElement("div");
div.className = "explorer-item";
div.textContent = subject.name;
div.addEventListener("click", () => {
document.querySelectorAll(".explorer-item").forEach((item) => item.classList.remove("active"));
div.classList.add("active");
loadSubject(index);
});
if (index === 0) {
div.classList.add("active");
}
div.addEventListener("contextmenu", (e) => {
e.preventDefault();
if (confirm(`确定要删除科目 ${subject.name} 吗?`)) {
currentData.subjects.splice(index, 1);
saveSchedule();
refreshSubjectList();
}
});
container.appendChild(div);
});
}
// 加载某计划
function loadSchedule(index) {
currentScheduleIndex = index;
document.getElementById("schedule-editor").style.display = "block";
const schedule = currentData.schedules[index];
const [weekMode, dayMode] = schedule.name.split("_");
document.getElementById("week-mode").value = weekMode
document.getElementById("day-mode").value = dayMode
refreshClassList();
}
// 加载某科目
function loadSubject(index) {
const subject = currentData.subjects[index];
document.getElementById("subject-name").value = subject.name;
document.getElementById("subject-simple").value = subject.simple || "";
document.getElementById("subject-teacher").value =
subject.teacher || "";
document.getElementById("subject-room").value = subject.room || "";
document.getElementById("subject-editor").style.display = "block";
}
// 刷新课程列表
function refreshClassList() {
const container = document.getElementById("class-list");
container.innerHTML = "";
currentData.schedules[currentScheduleIndex].classes.forEach(
(cls, index) => {
const card = document.createElement("div");
card.className = "class-card";
card.innerHTML = `
<select class="subject-select" onchange="saveClass(${index})">
${currentData.subjects
.map(
(s) =>
`<option value="${s.name}" ${
s.name === cls.subject ? "selected" : ""
}>${s.name}</option>`
)
.join("")}
</select>
<input type="time" class="time-input" value="${
cls.start_time
}" onchange="saveClass(${index})">
<input type="time" class="time-input" value="${
cls.end_time
}" onchange="saveClass(${index})">
<button onclick="deleteClass(${index})">删除</button>
`;
container.appendChild(card);
}
);
// 初始化拖拽排序
new Sortable(container, {
animation: 150,
onEnd: saveSchedule,
});
}
// 刷新计划列表
function refreshScheduleList() {
initSchedules();
}
// 刷新科目列表
function refreshSubjectList() {
initSubjects();
}
// 保存课程安排
function saveSchedule() {
// 更新数据逻辑
localStorage.setItem("csesData", JSON.stringify(currentData));
}
// 保存课时
function saveClass(index) {
const container = document.getElementById("class-list").children[index];
const subject = container.querySelector(".subject-select").value;
const start_time = container.querySelector(".time-input").value;
const end_time = container.querySelector(".time-input").value;
currentData.schedules[currentScheduleIndex].classes[index] = {
subject,
start_time,
end_time,
};
saveSchedule();
}
// 删除课时
function deleteClass(index) {
currentData.schedules[currentScheduleIndex].classes.splice(index, 1);
saveSchedule();
refreshClassList();
}
// 文件导入
async function importFile() {
const fileInput = document.getElementById("file-input");
fileInput.onchange = (e) => {
const file = e.target.files[0];
const reader = new FileReader();
reader.onload = (e) => {
try {
const data = jsyaml.load(e.target.result);
currentData = data;
saveSchedule();
location.reload();
} catch (error) {
alert(`导入失败: ${error}`);
}
};
reader.readAsText(file);
};
fileInput.click();
}
// 文件导出
function exportFile() {
const yamlStr = jsyaml.dump(currentData);
const blob = new Blob([yamlStr], { type: "text/yaml" });
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "schedule.yaml";
link.click();
}
// 清空数据
function clearData() {
if (confirm("确定要清空所有数据吗?")) {
localStorage.clear();
currentData = { version: 1, subjects: [], schedules: [] };
location.reload();
}
}
// 初始化拖拽导入
function initDragDrop() {
document.addEventListener("dragover", (e) => e.preventDefault());
document.addEventListener("drop", async (e) => {
e.preventDefault();
const file = e.dataTransfer.files[0];
if (file) await importFile(file);
});
}
// 添加新课程
function addNewClass() {
const newSchedule = {
name: "无规则计划",
classes: [],
};
currentData.schedules.push(newSchedule);
saveSchedule();
refreshScheduleList();
}
// 添加新课时
function addNewClassTime() {
currentData.schedules[currentScheduleIndex].classes.push({
subject: "",
start_time: "",
end_time: "",
});
saveSchedule();
refreshClassList();
}
// 添加新科目
function addNewSubject() {
const name = prompt("请输入科目名称:");
if (name) {
currentData.subjects.push({ name });
saveSchedule();
refreshSubjectList();
}
}
const weekMap = {
odd: "单周",
even: "双周",
all: "通用",
};
const dayMap = {
mon: "星期一",
tue: "星期二",
wed: "星期三",
thu: "星期四",
fri: "星期五",
sat: "星期六",
sun: "星期日",
};
// 更新计划名称
function updateSchedule() {
const weekMode = document.getElementById("week-mode").value;
const dayMode = document.getElementById("day-mode").value;
const scheduleName = `${weekMode}_${dayMode}`;
currentData.schedules[currentScheduleIndex].name = scheduleName;
currentData.schedules[currentScheduleIndex].enable_day = dayMode;
currentData.schedules[currentScheduleIndex].weeks = weekMode;
saveSchedule();
refreshScheduleList();
}
// 保存科目
function saveSubject() {
const name = document.getElementById("subject-name").value;
const simple = document.getElementById("subject-simple").value;
const room = document.getElementById("subject-room").value;
const teacher = document.getElementById("subject-teacher").value;
if (name) {
let subjectIndex = currentData.subjects.findIndex(subject => subject.name === name);
if (subjectIndex !== -1) {
currentData.subjects[subjectIndex].simple = simple;
currentData.subjects[subjectIndex].room = room;
currentData.subjects[subjectIndex].teacher = teacher;
} else {
currentData.subjects.push({ name, simple, room, teacher });
subjectIndex = currentData.subjects.length - 1;
}
saveSchedule();
refreshSubjectList();
document.querySelectorAll(".explorer-item").forEach((item, index) => {
item.classList.toggle("active", index === subjectIndex);
});
} else {
alert("请填写完整的科目信息");
}
}
function copySchdule() {
const newSchedule = JSON.parse(JSON.stringify(currentData.schedules[currentScheduleIndex]));
newSchedule.name = "无规则计划";
currentData.schedules.push(newSchedule);
saveSchedule();
refreshScheduleList();
}
// 处理快捷键
document.addEventListener("keydown", (e) => {
if (e.ctrlKey && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
e.preventDefault();
moveExplorerItem(e.key === "ArrowUp" ? -1 : 1);
} else if (e.altKey && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
e.preventDefault();
moveActivityItem(e.key === "ArrowUp" ? -1 : 1);
}
// 删除当前选中的项目
else if (e.key === "Delete") {
e.preventDefault();
const activeItem = document.querySelector(".explorer-item.active");
if (activeItem) {
const currentView = document.querySelector(".activity-item.active").dataset.view;
if (currentView === "schedule") {
const index = Array.from(document.querySelectorAll("#schedule-list .explorer-item")).indexOf(activeItem);
if (index !== -1) {
currentData.schedules.splice(index, 1);
saveSchedule();
refreshScheduleList();
}
} else if (currentView === "subject") {
const index = Array.from(document.querySelectorAll("#subject-list .explorer-item")).indexOf(activeItem);
if (index !== -1) {
currentData.subjects.splice(index, 1);
saveSchedule();
refreshSubjectList();
}
}
}
}
// 新增课程或科目
else if (e.altKey && e.key === "n") {
e.preventDefault();
const currentView = document.querySelector(".activity-item.active").dataset.view;
if (currentView === "schedule") {
addNewClass();
} else if (currentView === "subject") {
addNewSubject();
}
}
});
// 在资源管理器中移动项目
function moveExplorerItem(direction) {
const activeItem = document.querySelector(".explorer-item.active");
if (!activeItem) return;
const currentView = document.querySelector(".activity-item.active").dataset.view;
const items = Array.from(document.querySelectorAll(`#${currentView}-list .explorer-item`));
const currentIndex = items.indexOf(activeItem);
const newIndex = currentIndex + direction;
if (newIndex >= 0 && newIndex < items.length) {
items[currentIndex].classList.remove("active");
items[newIndex].classList.add("active");
items[newIndex].click();
}
}
// 在活动栏中移动项目
function moveActivityItem(direction) {
const activeItem = document.querySelector(".activity-item.active");
if (!activeItem) return;
const items = Array.from(document.querySelectorAll(".activity-item"));
const currentIndex = items.indexOf(activeItem);
const newIndex = currentIndex + direction;
if (newIndex >= 0 && newIndex < items.length) {
items[currentIndex].classList.remove("active");
items[newIndex].classList.add("active");
items[newIndex].click();
}
}
function keyHelp() {
showModal(`<h2>快捷键帮助</h2>
<b>Ctrl + ↑/↓:</b> 移动偏左栏中的项目
<b>Alt + ↑/↓:</b> 移动左栏中的项目
<b>Alt + N:</b> 新增课程或科目
<b>Delete:</b> 删除当前选中的项目
`);
}
function about() {
showModal(`<h2>CSES课程表编辑器 v1.0</h1>
<i>CSES是指The Course Schedule Exchange Schema,
是一种用于课程表交换的数据格式。
本工具旨在帮助用户快速编辑CSES格式的课程表。</i>
<br>
作者: PYLXU(CSES-org)
许可: MIT`);
}
function showModal(content) {
const modal = document.createElement("div");
modal.style.position = "fixed";
modal.style.top = "50%";
modal.style.left = "50%";
modal.style.transform = "translate(-50%, -50%)";
modal.style.background = "var(--bg-color)";
modal.style.color = "var(--text-color)";
modal.style.padding = "1rem";
modal.style.border = "1px solid var(--border-color)";
modal.style.borderRadius = "4px";
modal.style.zIndex = "1000";
modal.innerHTML = `
<div>${content.replace(/\n/g, "<br>")}</div>
<button onclick="this.parentElement.remove()" style="margin-top: 1rem;width:100%">关闭</button>
`;
document.body.appendChild(modal);
}
// 启动应用
init();
</script>
</body>
</html>