-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
33 lines (28 loc) · 896 Bytes
/
script.js
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
let count = 0;
let testStarted = false;
let timer = null;
document.getElementById('testButton').addEventListener('click', function() {
if (!testStarted) {
testStarted = true;
timer = setTimeout(endTest, 1000); // 默认1秒,可调整
}
count++;
updateSpeedDisplay();
});
document.getElementById('resetButton').addEventListener('click', function() {
resetTest();
});
function updateSpeedDisplay() {
const speedDisplay = document.getElementById('speedDisplay');
speedDisplay.textContent = `手速:${count} 次/秒`;
}
function endTest() {
document.getElementById('testButton').style.display = 'none';
clearTimeout(timer);
}
function resetTest() {
count = 0;
testStarted = false;
document.getElementById('testButton').style.display = 'block'; // 确保按钮显示
updateSpeedDisplay();
}