Skip to content

Commit

Permalink
Merge pull request #1 from harshsinghcs/feature
Browse files Browse the repository at this point in the history
bug fixed
  • Loading branch information
harshsinghcs authored Oct 15, 2023
2 parents 6a7529f + 9f21c8e commit cad8e5e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ <h2 class="text-xl mb-4">Pomodoro Timer</h2>
<button onclick="startTimer()" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 mr-2 rounded-md"><i class="fa-solid fa-play"></i></button>
<button onclick="pauseTimer()" class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 mr-2 rounded-md"><i class="fa-solid fa-pause"></i></button>
<button onclick="resetTimer()" class="bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded-md"><i class="fa-solid fa-arrows-rotate"></i></button>
<button onclick="setShortBreak()" class="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 mr-2 rounded-md"><i class="fa-solid fa-shield-halved" style="color: #0fd7c9;"></i></button>
<button onclick="setLongBreak()" class="bg-yellow-500 hover:bg-yellow-700 text-white font-bold py-2 px-4 rounded-md">Long Break</button>
</div>
</div>

Expand Down
44 changes: 43 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ let timer;
let minutes = 25;
let seconds = 0;
let isPaused = true;
let pomodoroCount = 0;
let isBreak = false;
let shortBreakDuration = 5; // Duration of short break in minutes
let longBreakDuration = 15; // Duration of long break in minutes

function startTimer() {
isPaused = false;
Expand All @@ -16,6 +20,7 @@ function startTimer() {
function pauseTimer() {
isPaused = true;
clearInterval(timer);
updateDisplay(); // Update the timer display to show the paused time
}

function resetTimer() {
Expand All @@ -28,7 +33,20 @@ function resetTimer() {

function updateTimer() {
if (minutes === 0 && seconds === 0) {
clearInterval(timer);
if (isBreak) {
// Handle the end of a break (short or long)
isBreak = false; // Reset the break flag
} else {
if (pomodoroCount >= 4) {
// It's time for a long break
minutes = longBreakDuration;
} else {
// It's time for a short break
minutes = shortBreakDuration;
}
isBreak = true; // Set the break flag
pomodoroCount++; // Increment the pomodoro count
}
// Add a notification or alert here when the timer finishes
} else {
if (seconds === 0) {
Expand All @@ -46,6 +64,26 @@ function updateDisplay() {
timerDisplay.textContent = `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
}

//ShortBreak
function setShortBreak() {
isPaused = true;
clearInterval(timer);
minutes = shortBreakDuration;
seconds = 0;
isBreak = true; // Set the break flag
updateDisplay();
}

//longBreak
function setLongBreak() {
isPaused = true;
clearInterval(timer);
minutes = longBreakDuration;
seconds = 0;
isBreak = true; // Set the break flag
updateDisplay();
}

// Initialize the display
updateDisplay();

Expand Down Expand Up @@ -163,6 +201,10 @@ function unassignPrimaryTask() {
}
}





// Website Blocker
// Add JavaScript code for website blocker here

Expand Down

0 comments on commit cad8e5e

Please sign in to comment.