Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

50Projects-HTML-CSS-JavaScript : Pomodoro timer#47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tajulafreen merged 3 commits intomainfromPomodoro_Timer
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
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
13 changes: 13 additions & 0 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -496,6 +496,19 @@ In order to run this project you need:
</details>
</li>

<li>
<details>
<summary>Pomodoro Timer</summary>
<p>The Productivity Timer (Pomodoro Timer) is a simple yet effective timer application based on the Pomodoro technique. It helps users stay productive by alternating between focus intervals (e.g., 5 minutes) and short breaks (e.g., 2 minutes). The app provides visual cues through animations and sound alerts to signal transitions between focus and break periods.

</p>
<ul>
<li><a href="https://tajulafreen.github.io/50Projects-HTML-CSS-JavaScript/Source-Code/PomodoroTimer/">Live Demo</a></li>
<li><a href="https://github.com/tajulafreen/50Projects-HTML-CSS-JavaScript/tree/main/Source-Code/PomodoroTimer">Source</a></li>
</ul>
</details>
</li>

</ol>

<p align="right">(<a href="#readme-top">back to top</a>)</p>
Expand Down
23 changes: 23 additions & 0 deletionsSource-Code/PomodoroTimer/index.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Productivity Timer</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Productivity Timer</h1>
<div class="timer-display">
<span id="minutes">25</span>:<span id="seconds">00</span>
</div>
<div class="controls">
<button id="start-btn">Start</button>
<button id="reset-btn">Reset</button>
</div>
<p id="status">Focus Session</p>
</div>
<script src="script.js"></script>
</body>
</html>
54 changes: 54 additions & 0 deletionsSource-Code/PomodoroTimer/script.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
const startBtn = document.getElementById('start-btn');
const resetBtn = document.getElementById('reset-btn');
const minutesDisplay = document.getElementById('minutes');
const secondsDisplay = document.getElementById('seconds');
const statusDisplay = document.getElementById('status');

let timerInterval;
let isFocusSession = true; // Start with a focus session
const focusTime = 5 * 60; // 5 minutes in seconds
const breakTime = 5 * 60; // 5 minutes in seconds
let timeRemaining = focusTime;

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');
};

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

const startTimer = () => {
if (timerInterval) return; // Prevent multiple intervals
timerInterval = setInterval(() => {
if (timeRemaining > 0) {
timeRemaining -= 1;
updateDisplay();
} else {
clearInterval(timerInterval);
timerInterval = null;
toggleSession();
}
}, 1000);
};

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

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

// Initialize display
updateDisplay();
51 changes: 51 additions & 0 deletionsSource-Code/PomodoroTimer/style.css
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
body {
font-family: Arial, sans-serif;
background-color: #f0f4f8;
color: #333;
text-align: center;
margin: 0;
padding: 0;
}

.container {
max-width: 400px;
margin: 100px auto;
padding: 20px;
background: #fff;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

h1 {
margin-bottom: 20px;
}

.timer-display {
font-size: 3rem;
margin: 20px 0;
}

.controls button {
font-size: 1rem;
padding: 10px 20px;
margin: 5px;
border: none;
border-radius: 5px;
cursor: pointer;
}

#start-btn {
background-color: #28a745;
color: white;
}

#reset-btn {
background-color: #dc3545;
color: white;
}

#status {
font-size: 1.2rem;
margin-top: 20px;
color: #555;
}

[8]ページ先頭

©2009-2025 Movatter.jp