zenpomodor-timer / index.html

Commit History

  1. use the following code and edit the code to include ambient sounds and a beeping sound when timer goes to zero, also include an option to reset the timer and add any time that the user needs, <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Pomodoro timer-ZenPomo - Focus Timer</title> <script src="https://cdn.tailwindcss.com"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> @keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } } .pulse-animation { animation: pulse 2s infinite; } .progress-ring__circle { transition: stroke-dashoffset 0.35s; transform: rotate(-90deg); transform-origin: 50% 50%; } .tab-active { background-color: rgba(255, 255, 255, 0.2); } </style> </head> <body class="bg-gradient-to-br from-indigo-900 to-purple-800 min-h-screen text-white font-sans"> <div class="container mx-auto px-4 py-8 flex flex-col items-center"> <header class="mb-8 text-center"> <h1 class="text-4xl font-bold mb-2">ZenPomo</h1> <p class="text-indigo-200">Focus in intervals, achieve more</p> </header> <div class="bg-white/10 backdrop-blur-sm rounded-2xl p-6 w-full max-w-md shadow-xl"> <!-- Timer Modes --> <div class="flex justify-center mb-6 bg-indigo-800/30 rounded-full p-1"> <button id="pomodoro-btn" class="tab-active px-4 py-2 rounded-full font-medium transition-all">Pomodoro</button> <button id="short-break-btn" class="px-4 py-2 rounded-full font-medium transition-all">Short Break</button> <button id="long-break-btn" class="px-4 py-2 rounded-full font-medium transition-all">Long Break</button> </div> <!-- Timer Display --> <div class="relative flex justify-center mb-8"> <svg class="w-64 h-64"> <circle class="text-indigo-700/30" stroke-width="8" stroke="currentColor" fill="transparent" r="112" cx="128" cy="128" /> <circle id="progress-ring" class="progress-ring__circle text-indigo-400" stroke-width="8" stroke-linecap="round" stroke="currentColor" fill="transparent" r="112" cx="128" cy="128" stroke-dasharray="704" stroke-dashoffset="0" /> </svg> <div class="absolute inset-0 flex flex-col items-center justify-center"> <div id="time-display" class="text-6xl font-bold mb-2">25:00</div> <button id="start-btn" class="bg-white text-indigo-800 px-8 py-3 rounded-full font-bold hover:bg-indigo-100 transition-all"> START </button> </div> </div> <!-- Settings --> <div class="bg-indigo-800/20 rounded-xl p-4 mb-6"> <h3 class="font-medium mb-3 text-center">Timer Settings</h3> <div class="grid grid-cols-3 gap-4"> <div> <label class="block text-sm text-indigo-200 mb-1">Pomodoro</label> <input id="pomodoro-time" type="number" min="1" max="60" value="25" class="w-full bg-indigo-800/30 rounded-md px-3 py-2 text-center"> </div> <div> <label class="block text-sm text-indigo-200 mb-1">Short Break</label> <input id="short-break-time" type="number" min="1" max="30" value="5" class="w-full bg-indigo-800/30 rounded-md px-3 py-2 text-center"> </div> <div> <label class="block text-sm text-indigo-200 mb-1">Long Break</label> <input id="long-break-time" type="number" min="1" max="60" value="15" class="w-full bg-indigo-800/30 rounded-md px-3 py-2 text-center"> </div> </div> </div> <!-- Task List --> <div class="bg-indigo-800/20 rounded-xl p-4"> <h3 class="font-medium mb-3 text-center">Today's Tasks</h3> <div class="flex mb-3"> <input id="task-input" type="text" placeholder="Add a task..." class="flex-1 bg-indigo-800/30 rounded-l-md px-3 py-2 focus:outline-none"> <button id="add-task-btn" class="bg-indigo-600 px-4 rounded-r-md hover:bg-indigo-700 transition-all"> <i class="fas fa-plus"></i> </button> </div> <ul id="task-list" class="space-y-2 max-h-40 overflow-y-auto"> <!-- Tasks will be added here --> </ul> </div> </div> <!-- Stats --> <div class="mt-6 text-center text-indigo-200"> <p>Pomodoros completed today: <span id="pomo-count" class="font-bold">0</span></p> </div> </div> <!-- Notification Sound --> <audio id="alarm-sound" src="https://assets.mixkit.co/sfx/preview/mixkit-alarm-digital-clock-beep-989.mp3" preload="auto"></audio> <script> // DOM Elements const timeDisplay = document.getElementById('time-display'); const startBtn = document.getElementById('start-btn'); const pomodoroBtn = document.getElementById('pomodoro-btn'); const shortBreakBtn = document.getElementById('short-break-btn'); const longBreakBtn = document.getElementById('long-break-btn'); const progressRing = document.getElementById('progress-ring'); const alarmSound = document.getElementById('alarm-sound'); const pomodoroTimeInput = document.getElementById('pomodoro-time'); const shortBreakTimeInput = document.getElementById('short-break-time'); const longBreakTimeInput = document.getElementById('long-break-time'); const taskInput = document.getElementById('task-input'); const addTaskBtn = document.getElementById('add-task-btn'); const taskList = document.getElementById('task-list'); const pomoCount = document.getElementById('pomo-count'); // Timer variables let timer; let timeLeft = 25 * 60; // 25 minutes in seconds let isRunning = false; let currentMode = 'pomodoro'; // 'pomodoro', 'shortBreak', 'longBreak' let pomodorosCompleted = 0; let pomodoroLength = 25; let shortBreakLength = 5; let longBreakLength = 15; const circumference = 2 * Math.PI * 112; // Initialize updateDisplay(); updateProgressRing(); // Event Listeners startBtn.addEventListener('click', toggleTimer); pomodoroBtn.addEventListener('click', () => switchMode('pomodoro')); shortBreakBtn.addEventListener('click', () => switchMode('shortBreak')); longBreakBtn.addEventListener('click', () => switchMode('longBreak')); pomodoroTimeInput.addEventListener('change', updateTimerSettings); shortBreakTimeInput.addEventListener('change', updateTimerSettings); longBreakTimeInput.addEventListener('change', updateTimerSettings); addTaskBtn.addEventListener('click', addTask); taskInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') addTask(); }); // Functions function toggleTimer() { if (isRunning) { pauseTimer(); } else { startTimer(); } } function startTimer() { isRunning = true; startBtn.textContent = 'PAUSE'; startBtn.classList.remove('bg-white', 'text-indigo-800'); startBtn.classList.add('bg-amber-400', 'text-amber-900'); timer = setInterval(() => { timeLeft--; updateDisplay(); updateProgressRing(); if (timeLeft <= 0) { clearInterval(timer); alarmSound.play(); isRunning = false; startBtn.textContent = 'START'; startBtn.classList.remove('bg-amber-400', 'text-amber-900'); startBtn.classList.add('bg-white', 'text-indigo-800'); if (currentMode === 'pomodoro') { pomodorosCompleted++; pomoCount.textContent = pomodorosCompleted; // Auto-switch to short break after 4 pomodoros if (pomodorosCompleted % 4 === 0) { setTimeout(() => switchMode('longBreak'), 1000); } else { setTimeout(() => switchMode('shortBreak'), 1000); } } else { setTimeout(() => switchMode('pomodoro'), 1000); } } }, 1000); } function pauseTimer() { clearInterval(timer); isRunning = false; startBtn.textContent = 'START'; startBtn.classList.remove('bg-amber-400', 'text-amber-900'); startBtn.classList.add('bg-white', 'text-indigo-800'); } function updateDisplay() { const minutes = Math.floor(timeLeft / 60); const seconds = timeLeft % 60; timeDisplay.textContent = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; // Add pulse animation when time is running low if (timeLeft <= 60 && isRunning) { timeDisplay.classList.add('pulse-animation', 'text-amber-400'); } else { timeDisplay.classList.remove('pulse-animation', 'text-amber-400'); } } function updateProgressRing() { let totalTime; if (currentMode === 'pomodoro') totalTime = pomodoroLength * 60; else if (currentMode === 'shortBreak') totalTime = shortBreakLength * 60; else totalTime = longBreakLength * 60; const offset = circumference - (timeLeft / totalTime) * circumference; progressRing.style.strokeDashoffset = offset; } function switchMode(mode) { currentMode = mode; // Update active tab pomodoroBtn.classList.remove('tab-active'); shortBreakBtn.classList.remove('tab-active'); longBreakBtn.classList.remove('tab-active'); if (mode === 'pomodoro') { pomodoroBtn.classList.add('tab-active'); timeLeft = pomodoroLength * 60; progressRing.classList.remove('text-emerald-400', 'text-amber-400'); progressRing.classList.add('text-indigo-400'); } else if (mode === 'shortBreak') { shortBreakBtn.classList.add('tab-active'); timeLeft = shortBreakLength * 60; progressRing.classList.remove('text-indigo-400', 'text-amber-400'); progressRing.classList.add('text-emerald-400'); } else { longBreakBtn.classList.add('tab-active'); timeLeft = longBreakLength * 60; progressRing.classList.remove('text-indigo-400', 'text-emerald-400'); progressRing.classList.add('text-amber-400'); } if (isRunning) { pauseTimer(); } updateDisplay(); updateProgressRing(); } function updateTimerSettings() { pomodoroLength = parseInt(pomodoroTimeInput.value) || 25; shortBreakLength = parseInt(shortBreakTimeInput.value) || 5; longBreakLength = parseInt(longBreakTimeInput.value) || 15; if (!isRunning) { if (currentMode === 'pomodoro') timeLeft = pomodoroLength * 60; else if (currentMode === 'shortBreak') timeLeft = shortBreakLength * 60; else timeLeft = longBreakLength * 60; updateDisplay(); updateProgressRing(); } } function addTask() { const taskText = taskInput.value.trim(); if (taskText) { const taskItem = document.createElement('li'); taskItem.className = 'flex items-center bg-indigo-800/30 rounded-md px-3 py-2'; const checkbox = document.createElement('input'); checkbox.type = 'checkbox'; checkbox.className = 'mr-2'; checkbox.addEventListener('change', function() { if (this.checked) { taskTextSpan.style.textDecoration = 'line-through'; taskTextSpan.style.opacity = '0.7'; } else { taskTextSpan.style.textDecoration = 'none'; taskTextSpan.style.opacity = '1'; } }); const taskTextSpan = document.createElement('span'); taskTextSpan.className = 'flex-1'; taskTextSpan.textContent = taskText; const deleteBtn = document.createElement('button'); deleteBtn.className = 'text-indigo-300 hover:text-white ml-2'; deleteBtn.innerHTML = '<i class="fas fa-trash-alt"></i>'; deleteBtn.addEventListener('click', function() { taskItem.remove(); }); taskItem.appendChild(checkbox); taskItem.appendChild(taskTextSpan); taskItem.appendChild(deleteBtn); taskList.appendChild(taskItem); taskInput.value = ''; } } </script> </body> </html> am - Initial Deployment

    Verified signature
    48266ea
  2. initial commit

    Verified signature
    8df43d2