Update index.html
Browse files- index.html +61 -1
index.html
CHANGED
@@ -49,6 +49,13 @@
|
|
49 |
cursor: pointer;
|
50 |
}
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
.controls button {
|
53 |
background-color: var(--color-active);
|
54 |
color: var(--color-bg);
|
@@ -153,11 +160,18 @@
|
|
153 |
<label for="seconds-input">Seconds:</label>
|
154 |
<input type="number" id="seconds-input" value="0" min="0">
|
155 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
<button id="start-timer">Start Timer</button>
|
158 |
<button id="pause">Pause</button>
|
159 |
<button id="reset">Reset</button>
|
160 |
-
<div style="text-align:bottom;"> | </div>
|
161 |
<button id="start-stopwatch">Start Stopwatch</button>
|
162 |
</div>
|
163 |
|
@@ -273,6 +287,52 @@
|
|
273 |
}
|
274 |
}
|
275 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
|
277 |
// Make sure the start function doesn't reset totalSeconds when resuming
|
278 |
function start() {
|
|
|
49 |
cursor: pointer;
|
50 |
}
|
51 |
|
52 |
+
.controls input[type="color"] {
|
53 |
+
border: none;
|
54 |
+
padding: 0;
|
55 |
+
width: 40px;
|
56 |
+
height: 40px;
|
57 |
+
}
|
58 |
+
|
59 |
.controls button {
|
60 |
background-color: var(--color-active);
|
61 |
color: var(--color-bg);
|
|
|
160 |
<label for="seconds-input">Seconds:</label>
|
161 |
<input type="number" id="seconds-input" value="0" min="0">
|
162 |
</div>
|
163 |
+
<div>
|
164 |
+
<label for="active-dot-color">Active Dot Color:</label>
|
165 |
+
<input type="color" id="active-dot-color" value="#f39c12">
|
166 |
+
</div>
|
167 |
+
<div>
|
168 |
+
<label for="inactive-dot-color">Inactive Dot Color:</label>
|
169 |
+
<input type="color" id="inactive-dot-color" value="#555555">
|
170 |
+
</div>
|
171 |
|
172 |
<button id="start-timer">Start Timer</button>
|
173 |
<button id="pause">Pause</button>
|
174 |
<button id="reset">Reset</button>
|
|
|
175 |
<button id="start-stopwatch">Start Stopwatch</button>
|
176 |
</div>
|
177 |
|
|
|
287 |
}
|
288 |
}
|
289 |
}
|
290 |
+
//ADDED
|
291 |
+
// Get references to the new color inputs
|
292 |
+
const activeDotColorInput = document.getElementById('active-dot-color');
|
293 |
+
const inactiveDotColorInput = document.getElementById('inactive-dot-color');
|
294 |
+
|
295 |
+
// Function to update CSS variables for dot colors
|
296 |
+
function updateDotColors() {
|
297 |
+
document.documentElement.style.setProperty('--color-active', activeDotColorInput.value);
|
298 |
+
document.documentElement.style.setProperty('--color-inactive', inactiveDotColorInput.value);
|
299 |
+
|
300 |
+
// Update all dots' colors immediately
|
301 |
+
const allDots = document.querySelectorAll('.dot');
|
302 |
+
allDots.forEach(dot => {
|
303 |
+
if (dot.classList.contains('active')) {
|
304 |
+
dot.style.backgroundColor = activeDotColorInput.value;
|
305 |
+
} else {
|
306 |
+
dot.style.backgroundColor = inactiveDotColorInput.value;
|
307 |
+
}
|
308 |
+
});
|
309 |
+
}
|
310 |
+
|
311 |
+
// Event listeners for color changes
|
312 |
+
activeDotColorInput.addEventListener('input', updateDotColors);
|
313 |
+
inactiveDotColorInput.addEventListener('input', updateDotColors);
|
314 |
+
|
315 |
+
// Modify the updateGridRow function to use the new color system
|
316 |
+
function updateGridRow(rows, previous, current, max) {
|
317 |
+
const start = Math.min(previous, current);
|
318 |
+
const end = Math.max(previous, current);
|
319 |
+
|
320 |
+
for (let i = start; i < end; i++) {
|
321 |
+
const rowIndex = Math.floor(i / (max / rows.length));
|
322 |
+
const dotIndex = i % (max / rows.length);
|
323 |
+
const dot = rows[rowIndex].children[dotIndex];
|
324 |
+
if (dot) {
|
325 |
+
dot.classList.remove('active', 'inactive');
|
326 |
+
dot.classList.add(i < current ? 'active' : 'inactive');
|
327 |
+
// Apply the color directly here for immediate visual feedback
|
328 |
+
dot.style.backgroundColor = i < current ? activeDotColorInput.value : inactiveDotColorInput.value;
|
329 |
+
}
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
// Initial update to set default colors
|
334 |
+
updateDotColors();
|
335 |
+
//ADDED STOP
|
336 |
|
337 |
// Make sure the start function doesn't reset totalSeconds when resuming
|
338 |
function start() {
|