Skip to content

Commit ddaf7da

Browse files
authored
1 parent a678b50 commit ddaf7da

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

pomodoro.html

+26-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@
9595
margin-top: 2rem;
9696
font-family: monospace;
9797
}
98+
.deleteBtn {
99+
background-color: transparent;
100+
border: none;
101+
color: #f44336;
102+
cursor: pointer;
103+
font-size: 1.2rem;
104+
padding: 0.2rem 0.5rem;
105+
}
106+
.deleteBtn:hover {
107+
color: #da190b;
108+
}
98109
</style>
99110
</head>
100111
<body>
@@ -128,6 +139,7 @@ <h2>Session Log</h2>
128139
<th>End Time</th>
129140
<th>Duration</th>
130141
<th>Pauses</th>
142+
<th>Action</th>
131143
</tr>
132144
</thead>
133145
<tbody id="sessionLogBody"></tbody>
@@ -283,18 +295,31 @@ <h2>Session Log</h2>
283295

284296
function updateSessionLog() {
285297
sessionLogBody.innerHTML = '';
286-
sessions.forEach(session => {
298+
sessions.forEach((session, index) => {
287299
const row = document.createElement('tr');
288300
row.innerHTML = `
289301
<td>${session.goal}</td>
290302
<td>${formatDate(session.startTime)}</td>
291303
<td>${session.endTime ? formatDate(session.endTime) : 'In progress'}</td>
292304
<td>${formatDuration(session.duration)}</td>
293305
<td>${formatPauses(session.pauses)}</td>
306+
<td><button class="deleteBtn" data-index="${index}">❌</button></td>
294307
`;
295308
sessionLogBody.appendChild(row);
296309
});
297310
jsonOutput.value = JSON.stringify(sessions, null, 2);
311+
312+
// Add event listeners to delete buttons
313+
document.querySelectorAll('.deleteBtn').forEach(btn => {
314+
btn.addEventListener('click', deleteSession);
315+
});
316+
}
317+
318+
function deleteSession(event) {
319+
const index = parseInt(event.target.getAttribute('data-index'));
320+
sessions.splice(index, 1);
321+
updateSessionLog();
322+
saveSessions();
298323
}
299324

300325
function formatDuration(seconds) {

0 commit comments

Comments
 (0)