Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
followed es6
  • Loading branch information
tajulafreen committed Dec 22, 2024
commit 58eb81c2bc5646d93fdf7fec1eefa922eebe093b
16 changes: 8 additions & 8 deletions Source-Code/PomodoroTimer/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ const focusTime = 5 * 60; // 5 minutes in seconds
const breakTime = 5 * 60; // 5 minutes in seconds
let timeRemaining = focusTime;

function updateDisplay() {
const updateDisplay = () => {
const minutes = Math.floor(timeRemaining / 60);
const seconds = timeRemaining % 60;
minutesDisplay.textContent = String(minutes).padStart(2, '0');
secondsDisplay.textContent = String(seconds).padStart(2, '0');
}
};

function toggleSession() {
const toggleSession = () => {
isFocusSession = !isFocusSession;
timeRemaining = isFocusSession ? focusTime : breakTime;
statusDisplay.textContent = isFocusSession
? 'Focus Session'
: 'Break Session';
updateDisplay();
}
};

function startTimer() {
const startTimer = () => {
if (timerInterval) return; // Prevent multiple intervals
timerInterval = setInterval(() => {
if (timeRemaining > 0) {
Expand All @@ -38,14 +38,14 @@ function startTimer() {
toggleSession();
}
}, 1000);
}
};

function resetTimer() {
const resetTimer = () => {
clearInterval(timerInterval);
timerInterval = null;
timeRemaining = isFocusSession ? focusTime : breakTime;
updateDisplay();
}
};

startBtn.addEventListener('click', startTimer);
resetBtn.addEventListener('click', resetTimer);
Expand Down