Update script.js
Browse files
script.js
CHANGED
|
@@ -10,17 +10,24 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 10 |
let testDuration = 15; // Duration in seconds
|
| 11 |
|
| 12 |
function startTest() {
|
| 13 |
-
// Reset
|
| 14 |
clickCount = 0;
|
| 15 |
cpsDisplay.textContent = 'CPS: 0.00';
|
| 16 |
timerElement.textContent = testDuration;
|
| 17 |
-
clickButton.classList.add('white');
|
| 18 |
-
clickButton.textContent = clickCount;
|
| 19 |
|
| 20 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
intervalId = setInterval(updateTimer, 1000);
|
| 22 |
|
| 23 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
clickButton.removeEventListener('click', startTest);
|
| 25 |
clickButton.addEventListener('click', recordClick);
|
| 26 |
}
|
|
|
|
| 10 |
let testDuration = 15; // Duration in seconds
|
| 11 |
|
| 12 |
function startTest() {
|
| 13 |
+
// Reset the test state
|
| 14 |
clickCount = 0;
|
| 15 |
cpsDisplay.textContent = 'CPS: 0.00';
|
| 16 |
timerElement.textContent = testDuration;
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
// Ensure previous interval is cleared
|
| 19 |
+
if (intervalId) {
|
| 20 |
+
clearInterval(intervalId);
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
// Start a new timer
|
| 24 |
intervalId = setInterval(updateTimer, 1000);
|
| 25 |
|
| 26 |
+
// Update button state
|
| 27 |
+
clickButton.classList.add('white');
|
| 28 |
+
clickButton.textContent = clickCount;
|
| 29 |
+
|
| 30 |
+
// Set up event listeners for the button
|
| 31 |
clickButton.removeEventListener('click', startTest);
|
| 32 |
clickButton.addEventListener('click', recordClick);
|
| 33 |
}
|