13 · 2026

จับเวลาโฟกัส (Pomodoro)Focus Timer (Pomodoro)

จับเวลาอ่านหนังสือ 25 นาที พัก 5 นาที ผูกกับรายการงาน นับว่าแต่ละงานใช้กี่รอบ และดูสถิติการโฟกัส 7 วัน25-minute focus / 5-minute break cycles tied to a task list, with rounds per task and a 7-day focus history.

tools/focus.ts
// จับเวลาจาก "เวลาสิ้นสุด" ไม่ใช่นับ setInterval// จึงแม่นแม้สลับแท็บหรือเครื่องหน่วงif (state.status === "running")  return Math.max(0, state.endsAt - now);
13TESTS7

ใช้ทำอะไร

  • โฟกัส 25 นาที → พักสั้น 5 นาที → ครบ 4 รอบได้พักยาว 15 นาที (ปรับเวลาได้)
  • เพิ่มรายการงาน เลือกงานที่กำลังทำ — ทุกรอบที่ครบจะนับให้งานนั้น
  • สถิติ: วันนี้กี่นาที, 7 วันล่าสุด, ทำต่อเนื่องกี่วัน
  • เสียงเตือนและการแจ้งเตือนเมื่ออยู่แท็บอื่น, เวลาขึ้นบนชื่อแท็บ
  • กด Space เริ่ม/หยุดได้

รายละเอียดทางเทคนิค

  • ตัวจับเวลาเก็บ "เวลาสิ้นสุด" แล้วคำนวณเวลาที่เหลือจากนาฬิกาจริง — browser มักหน่วง setInterval ในแท็บพื้นหลัง ถ้านับทีละวินาทีเวลาจะคลาด
  • logic เป็น state machine (idle / running / paused) ที่ test ได้โดยไม่ต้องรอเวลาจริง
  • ข้ามรอบ (Skip) จะไม่นับเป็นเวลาโฟกัส
  • เสียงสร้างด้วย Web Audio ไม่ต้องโหลดไฟล์

What it does

  • 25-minute focus → 5-minute break → a 15-minute long break every 4 rounds (all adjustable)
  • Add tasks and pick the current one — every finished round counts toward it
  • Stats: minutes today, the last 7 days, and your streak
  • Sound and background-tab notifications; the time shows in the tab title
  • Press Space to start or pause

Technical details

  • The timer stores an end timestamp and computes what's left from the real clock — browsers throttle setInterval in background tabs, so counting ticks drifts
  • The logic is a state machine (idle / running / paused) that's tested without waiting in real time
  • Skipping a round doesn't count as focus time
  • Sounds are synthesised with Web Audio — no files to load