-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
304 lines (266 loc) · 9.32 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pomodoro Timer with Tasks</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 20px;
background-color: #181616;
color: #333;
transition: background-color 0.3s, color 0.3s;
}
.container {
background-color: #fff;
border-radius: 8px;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
transition: background-color 0.3s, box-shadow 0.3s;
}
.timer {
text-align: center;
margin-bottom: 20px;
}
.task-list {
text-align: left;
width: 300px;
margin-bottom: 20px;
}
ul {
list-style-type: none;
padding: 0;
}
li {
margin-bottom: 10px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
border-radius: 4px;
transition: background-color 0.3s;
}
li:hover {
background-color: #565656;
color: whitesmoke;
}
li button {
background-color: transparent;
color: #ff6347;
border: none;
cursor: pointer;
transition: color 0.3s;
margin-left: 10px;
}
li button:hover {
color: #d32f2f;
}
#timer {
font-size: 4em;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
font-size: 1em;
margin: 0 10px;
cursor: pointer;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 4px;
transition: background-color 0.3s, color 0.3s;
}
.butt:hover {
background-color: #0056b3;
}
input[type="text"] {
padding: 8px;
margin-right: 5px;
width: 180px;
}
button.taskInput {
padding: 8px 15px;
font-size: 1em;
margin-top: 10px;
}
.taskInput {
margin-left: 0px;
}
input[type="number"] {
padding: 8px;
width: 60px;
font-size: 1em;
border: 1px solid #ccc;
border-radius: 4px;
margin-right: 5px;
margin-bottom: 10px;
}
input[type="number"]:focus {
outline: none;
border-color: #007bff;
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}
.toggle-dark {
display: flex;
align-items: center;
justify-content: center;
margin-top: 20px;
}
.toggle-btn {
padding: 8px 15px;
font-size: 1em;
cursor: pointer;
border: none;
border-radius: 4px;
background-color: #007bff;
color: #fff;
transition: background-color 0.3s, color 0.3s;
}
.toggle-btn:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<div class="timer">
<h1 id="timer">25:00</h1>
<input type="number" id="setTimer" placeholder="Set time (mins)" value=25>
<button id="updateTimer" class="butt">Update Timer</button>
<button id="startButton" class="butt">Start</button>
<button id="resetButton" class="butt">Reset</button>
</div>
<div class="task-list">
<h3>Task List</h3>
<input type="text" id="taskInput" placeholder="Add task...">
<button class="taskInput butt" onclick=" addTask()">Add Task</button>
<ul id="tasks"></ul>
</div>
<div class="toggle-dark">
<button id="darkModeToggle" class="toggle-btn" onclick="toggleDarkMode()">Dark Mode</button>
</div>
</div>
<script>
let timer;
let minutes = 25; // Initial Pomodoro length
let seconds = 0;
let isRunning = false;
const display = document.getElementById('timer');
const startButton = document.getElementById('startButton');
const resetButton = document.getElementById('resetButton');
const taskInput = document.getElementById('taskInput');
const taskList = document.getElementById('tasks');
const darkModeCheckbox = document.getElementById('darkMode');
const container = document.querySelector('.container');
const setTimerInput = document.getElementById('setTimer');
const updateTimerBtn = document.getElementById('updateTimer');
function updateDisplay() {
const displayMinutes = String(minutes).padStart(2, '0');
const displaySeconds = String(seconds).padStart(2, '0');
display.textContent = `${displayMinutes}:${displaySeconds}`;
}
function startTimer() {
if (!isRunning) {
isRunning = true;
timer = setInterval(() => {
if (seconds > 0) {
seconds--;
} else if (minutes > 0) {
seconds = 59;
minutes--;
} else {
clearInterval(timer);
isRunning = false;
// Perform actions on timer completion (e.g., switch to break time)
// You can add logic here for break time, long break, etc.
}
updateDisplay();
}, 1000);
}
}
function resetTimer() {
clearInterval(timer);
minutes = 25;
seconds = 0;
isRunning = false;
updateDisplay();
}
function addTask() {
const taskText = taskInput.value.trim();
if (taskText !== '') {
const taskItem = document.createElement('li');
taskItem.textContent = taskText;
const deleteButton = document.createElement('button');
deleteButton.id = 'Remove';
deleteButton.textContent = 'Remove';
deleteButton.onclick = function () {
taskList.removeChild(taskItem);
};
taskItem.appendChild(deleteButton);
taskList.appendChild(taskItem);
taskInput.value = '';
}
}
function addTask() {
const taskText = taskInput.value.trim();
if (taskText !== '') {
const taskItem = document.createElement('li');
taskItem.textContent = taskText;
const deleteButton = document.createElement('button');
deleteButton.id = 'Remove';
deleteButton.textContent = 'Remove';
deleteButton.onclick = function () {
taskList.removeChild(taskItem);
};
taskItem.appendChild(deleteButton);
taskList.appendChild(taskItem);
taskInput.value = '';
}
}
// Function to handle "Enter" key press in the task input field
taskInput.addEventListener('keypress', function (e) {
if (e.key === 'Enter') {
addTask();
}
});
function toggleDarkMode() {
if (darkModeCheckbox.checked) {
container.style.backgroundColor = '#333';
container.style.color = '#fff';
} else {
container.style.backgroundColor = '#fff';
container.style.color = '#333';
}
}
function updateTimer() {
const newTime = parseInt(setTimerInput.value);
if (!isNaN(newTime) && newTime > 0) {
minutes = newTime;
seconds = 0;
updateDisplay();
}
}
startButton.addEventListener('click', startTimer);
resetButton.addEventListener('click', resetTimer);
updateTimerBtn.addEventListener('click', updateTimer);
updateDisplay();
function toggleDarkMode() {
const darkModeToggle = document.getElementById('darkModeToggle');
if (darkModeToggle.textContent === 'Dark Mode') {
// Switch to dark mode
container.style.backgroundColor = '#333';
container.style.color = '#fff';
darkModeToggle.textContent = 'Light Mode';
} else {
// Switch to light mode
container.style.backgroundColor = '#fff';
container.style.color = '#333';
darkModeToggle.textContent = 'Dark Mode';
}
}
</script>
</body>
</html>