From 718fdd0191afa8521c30befa9e097eda8b611d59 Mon Sep 17 00:00:00 2001 From: Ingo Wolf Date: Fri, 8 Aug 2025 13:54:45 +1000 Subject: [PATCH 1/2] [With AI] add stopwatch and timer --- src/routes/tools/stopwatch-timer/+page.svelte | 444 ++++++++++++++++++ 1 file changed, 444 insertions(+) create mode 100644 src/routes/tools/stopwatch-timer/+page.svelte diff --git a/src/routes/tools/stopwatch-timer/+page.svelte b/src/routes/tools/stopwatch-timer/+page.svelte new file mode 100644 index 00000000..5e4b5445 --- /dev/null +++ b/src/routes/tools/stopwatch-timer/+page.svelte @@ -0,0 +1,444 @@ + + +
+ + + + + Stopwatch + + + + Timer + + + + + + + + + + Stopwatch + + + + +
+
+ {formatTime(stopwatchTime)} +
+ {#if stopwatchRunning} + +
+ Running +
+ {:else} + Stopped + {/if} +
+ + +
+ {#if !stopwatchRunning} + + {:else} + + {/if} + + + + {#if stopwatchRunning} + + {/if} +
+
+
+ + + {#if stopwatchLaps.length > 0} + + + Lap Times ({stopwatchLaps.length}) + + +
+ {#each stopwatchLaps.toReversed() as lap, index} + {@const lapIndex = stopwatchLaps.length - index} + {@const previousLap = stopwatchLaps[stopwatchLaps.length - index - 2]} + {@const splitTime = previousLap ? lap - previousLap : lap} +
+
Lap {lapIndex}
+
+ + +{formatTime(splitTime)} + + {formatTime(lap)} + +
+
+ {/each} +
+
+
+ {/if} +
+ + + + + + + + Timer + + + + + {#if !timerRunning && timerCurrentTime === 0} +
+
+ + +
+
+ + +
+
+ + +
+ +
+ {#each [{ label: '1 min', minutes: 1, seconds: 0 }, { label: '5 min', minutes: 5, seconds: 0 }, { label: '10 min', minutes: 10, seconds: 0 }, { label: '15 min', minutes: 15, seconds: 0 }, { label: '25 min', minutes: 25, seconds: 0 }, { label: '30 min', minutes: 30, seconds: 0 }, { label: '45 min', minutes: 45, seconds: 0 }, { label: '1 hour', minutes: 60, seconds: 0 }] as preset} + + {/each} +
+
+ {/if} + + +
+ {#if timerCurrentTime > 0 || timerRunning} +
+ {formatTime(timerCurrentTime, false)} +
+ {#if timerTotalTime > 0} +
+
+
+ {/if} + {:else} +
+ {String(timerMinutes).padStart(2, '0')}:{String(timerSeconds).padStart(2, '0')} +
+ {/if} + + {#if timerFinished} + + + Time's Up! + + {:else if timerRunning} + +
+ Running +
+ {:else if timerCurrentTime > 0} + Paused + {:else} + Ready + {/if} +
+ + +
+ {#if !timerRunning} + + {:else} + + {/if} + + +
+ + {#if timerFinished} +
+ +

Timer completed!

+

+ Your {formatTime(timerTotalTime, false)} timer has finished. +

+
+ {/if} +
+
+
+
+
+ + From ff10d956f121f0591c43b808e685d1e0f26709ba Mon Sep 17 00:00:00 2001 From: Ingo Wolf Date: Fri, 8 Aug 2025 13:56:10 +1000 Subject: [PATCH 2/2] remvoe keyboard shortcuts --- src/routes/tools/stopwatch-timer/+page.svelte | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/src/routes/tools/stopwatch-timer/+page.svelte b/src/routes/tools/stopwatch-timer/+page.svelte index 5e4b5445..6d8794ac 100644 --- a/src/routes/tools/stopwatch-timer/+page.svelte +++ b/src/routes/tools/stopwatch-timer/+page.svelte @@ -153,29 +153,6 @@ if (stopwatchInterval) clearInterval(stopwatchInterval); if (timerInterval) clearInterval(timerInterval); }); - - // Keyboard shortcuts - onMount(() => { - function handleKeydown(event: KeyboardEvent) { - if (event.target instanceof HTMLInputElement) return; - - switch (event.code) { - case 'Space': - event.preventDefault(); - // Toggle based on active tab - you'd need to track active tab - break; - case 'KeyR': - if (event.ctrlKey || event.metaKey) { - event.preventDefault(); - // Reset current timer/stopwatch - } - break; - } - } - - document.addEventListener('keydown', handleKeydown); - return () => document.removeEventListener('keydown', handleKeydown); - });