mirror of
https://github.com/ExamAware/ExamSchedule.git
synced 2025-04-29 19:16:33 +00:00

* refactor: 史诗级重构拆分多年狮山代码 * style: 添加设置模态框淡出动画,优化关闭和保存设置的用户体验 * style: 添加错误提示系统,优化用户体验,处理设置和全屏操作中的异常 * feat: 添加主题切换功能,支持亮/暗色模式,优化用户界面 * chore: 测试配置 * feat: 更新亮色主题背景和透明度 * style: 滑块居右 * feat: 初步实现 全是Bug * feat: 添加提醒队列功能,支持音频预加载和配置导出 * feat: 优化文件输入和按钮样式,提升用户交互体验 * feat: 添加时间广播功能,优化错误提示系统,移除不必要的设置选项 * feat: 移除不再使用的音频文件,更新课程结束时间,优化音频文件加载和选择功能
56 lines
3.2 KiB
JavaScript
56 lines
3.2 KiB
JavaScript
function saveSettingsToCookies() {
|
|
var table = document.getElementById('reminderTable');
|
|
var reminders = [];
|
|
for (var i = 1; i < table.rows.length - 1; i++) {
|
|
var row = table.rows[i];
|
|
var condition = row.cells[0].querySelector('select').value;
|
|
var timeInput = row.cells[1].querySelector('input');
|
|
var audioSelect = row.cells[2].querySelector('select');
|
|
if (timeInput && audioSelect) {
|
|
var time = timeInput.value || 0; // 确保时间值不为空
|
|
var audio = audioSelect.value || 'classStart'; // 确保音频选择不为空
|
|
reminders.push({ condition: condition, time: time, audio: audio });
|
|
}
|
|
}
|
|
document.cookie = "reminders=" + JSON.stringify(reminders);
|
|
}
|
|
|
|
function loadSettingsFromCookies() {
|
|
var cookies = document.cookie.split(';');
|
|
cookies.forEach(function(cookie) {
|
|
var parts = cookie.split('=');
|
|
var name = parts[0].trim();
|
|
var value = parts[1].trim();
|
|
if (name === 'reminders') {
|
|
var reminders = JSON.parse(value);
|
|
var table = document.getElementById('reminderTable');
|
|
reminders.forEach(function(reminder) {
|
|
var row = table.insertRow(table.rows.length - 1);
|
|
row.innerHTML = `
|
|
<td>
|
|
<select>
|
|
<option value="beforeStart" ${reminder.condition === 'beforeStart' ? 'selected' : ''}>当距离考试开始时间还有</option>
|
|
<option value="beforeEnd" ${reminder.condition === 'beforeEnd' ? 'selected' : ''}>当距离考试结束时间还有</option>
|
|
<option value="afterEnd" ${reminder.condition === 'afterEnd' ? 'selected' : ''}>当考试结束后</option>
|
|
<option value="start" ${reminder.condition === 'start' ? 'selected' : ''}>当考试开始时</option>
|
|
<option value="end" ${reminder.condition === 'end' ? 'selected' : ''}>当考试结束时</option>
|
|
</select>
|
|
</td>
|
|
<td><input type="number" value="${reminder.time}" placeholder="${reminder.condition === 'start' || reminder.condition === 'end' ? '-' : '分钟'}" ${reminder.condition === 'start' || reminder.condition === 'end' ? 'disabled' : ''}></td>
|
|
<td>
|
|
<select>
|
|
<option value="classStart" ${reminder.audio === 'classStart' ? 'selected' : ''}>考试开始铃声</option>
|
|
<option value="classEnd" ${reminder.audio === 'classEnd' ? 'selected' : ''}>考试结束铃声</option>
|
|
</select>
|
|
</td>
|
|
<td><button onclick="removeReminder(this)">删除</button></td>
|
|
`;
|
|
row.cells[0].querySelector('select').addEventListener('change', function() {
|
|
row.cells[1].querySelector('input').disabled = this.value === 'start' || this.value === 'end';
|
|
row.cells[1].querySelector('input').placeholder = this.value === 'start' || this.value === 'end' ? '-' : '分钟';
|
|
});
|
|
});
|
|
}
|
|
});
|
|
}
|