From f835658231a25e43d0b3e051c9ad17183b2d42a6 Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 20 Jul 2026 03:46:29 -0700 Subject: [PATCH] feat: pomodoro timer with Chrome background audio chime (#1) Single HTML prototype: configurable minutes, start/pause, scheduled Web Audio beep so the chime can fire while the tab is backgrounded, plus visibility re-sync for accurate countdown. --- pomodoro/README.md | 19 +++ pomodoro/index.html | 321 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 340 insertions(+) create mode 100644 pomodoro/README.md create mode 100644 pomodoro/index.html diff --git a/pomodoro/README.md b/pomodoro/README.md new file mode 100644 index 0000000..179cf51 --- /dev/null +++ b/pomodoro/README.md @@ -0,0 +1,19 @@ +# Pomodoro timer prototype ($200 bounty) + +Single-file Chrome-focused pomodoro timer with background-capable chime. + +## Files +- `index.html` — UI + timer + Web Audio scheduling + +## How background audio works +1. **User gesture unlock**: first **Start** or **Unlock background audio** creates/resumes an `AudioContext` (required by Chrome autoplay policy). +2. **Scheduled chime**: when the timer starts, a short oscillator beep is scheduled at `audioContext.currentTime + remainingSeconds`. Web Audio scheduled nodes continue to fire when the tab is backgrounded for typical short pomodoro durations. +3. **Display accuracy**: `setInterval` updates the clock; on `visibilitychange` remaining time is recomputed from `performance.now()` so throttled tabs do not drift. +4. **Secondary alert**: optional `Notification` when permission is granted. + +## Manual test +1. Open `index.html` in Chrome desktop. +2. Click **Unlock background audio** (or Start) once. +3. Set minutes to `1` (or use a short value and temporarily edit for 30s tests). +4. Start, switch to another tab/app, wait for end — chime should play. +5. Pause/resume and confirm countdown + reset after completion. diff --git a/pomodoro/index.html b/pomodoro/index.html new file mode 100644 index 0000000..5f33b38 --- /dev/null +++ b/pomodoro/index.html @@ -0,0 +1,321 @@ + + + + + + Pomodoro Timer — Background Audio + + + +
+

Pomodoro timer

+

+ Minimal single-page timer. Notification chime is unlocked on first Start + so Chrome can play audio when this tab is in the background. +

+ + + + +
25:00
+ +
+ + +
+ +

+
+ + + +