diff --git a/课堂点名小程序/课堂随机点名v1.7.html b/课堂点名小程序/课堂随机点名v1.7.html index 6389b99..6485503 100644 --- a/课堂点名小程序/课堂随机点名v1.7.html +++ b/课堂点名小程序/课堂随机点名v1.7.html @@ -21,7 +21,19 @@ color: #6a1b9a; font-size: 2.5em; text-shadow: 2px 2px 4px rgba(0,0,0,0.2); - margin-bottom: 30px; + margin-bottom: 20px; + } + + #counter { + background: rgba(255,255,255,0.8); + color: #e74c3c; + font-size: 1.3em; + font-weight: bold; + padding: 8px 15px; + border-radius: 15px; + display: inline-block; + margin-bottom: 15px; + box-shadow: 0 4px 6px rgba(0,0,0,0.1); } #display { @@ -124,6 +136,7 @@

课堂点名小程序

+
已点名: 0/0 人
点击开始
@@ -255,6 +268,13 @@ const speedControl = document.getElementById('speedControl'); let calledStudents = []; // 新增已点名学生数组 + // 更新计数器显示 + function updateCounter() { + const counter = document.getElementById('counter'); + const totalStudents = names.filter(student => !student.absent).length; + counter.textContent = `已点名: ${calledStudents.length}/${totalStudents} 人`; + } + // 初始化加载本地存储数据 document.addEventListener('DOMContentLoaded', () => { const savedData = localStorage.getItem('attendanceData'); @@ -264,6 +284,9 @@ const customTitle = prompt("请输入课堂名称:") || "杨老师的课堂"; document.getElementById('title').textContent = `${customTitle}点名系统`; + + // 初始化计数器 + updateCounter(); }); function toggleRoll() { @@ -305,6 +328,8 @@ // 新增:将当前学生加入已点名列表 if (currentStudent && !calledStudents.includes(currentStudent.id)) { calledStudents.push(currentStudent.id); + // 更新计数器 + updateCounter(); } } @@ -319,6 +344,8 @@ targetStudent.absent = true; localStorage.setItem('attendanceData', JSON.stringify(names)); alert(`已标记 ${targetStudent.name} 为未到场`); + // 更新计数器 + updateCounter(); // 如果正在点名则立即更新名单 if (isRolling) { clearInterval(intervalId); @@ -336,6 +363,8 @@ alert('考勤数据已重置!'); currentStudent = null; display.textContent = "点击开始"; + // 更新计数器 + updateCounter(); } } @@ -375,4 +404,4 @@ }); - \ No newline at end of file +