|
95 | 95 | margin-top: 2rem; |
96 | 96 | font-family: monospace; |
97 | 97 | } |
| 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 | + } |
98 | 109 | </style> |
99 | 110 | </head> |
100 | 111 | <body> |
@@ -128,6 +139,7 @@ <h2>Session Log</h2> |
128 | 139 | <th>End Time</th> |
129 | 140 | <th>Duration</th> |
130 | 141 | <th>Pauses</th> |
| 142 | + <th>Action</th> |
131 | 143 | </tr> |
132 | 144 | </thead> |
133 | 145 | <tbody id="sessionLogBody"></tbody> |
@@ -283,18 +295,31 @@ <h2>Session Log</h2> |
283 | 295 |
|
284 | 296 | function updateSessionLog() { |
285 | 297 | sessionLogBody.innerHTML = ''; |
286 | | - sessions.forEach(session => { |
| 298 | + sessions.forEach((session, index) => { |
287 | 299 | const row = document.createElement('tr'); |
288 | 300 | row.innerHTML = ` |
289 | 301 | <td>${session.goal}</td> |
290 | 302 | <td>${formatDate(session.startTime)}</td> |
291 | 303 | <td>${session.endTime ? formatDate(session.endTime) : 'In progress'}</td> |
292 | 304 | <td>${formatDuration(session.duration)}</td> |
293 | 305 | <td>${formatPauses(session.pauses)}</td> |
| 306 | + <td><button class="deleteBtn" data-index="${index}">❌</button></td> |
294 | 307 | `; |
295 | 308 | sessionLogBody.appendChild(row); |
296 | 309 | }); |
297 | 310 | 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(); |
298 | 323 | } |
299 | 324 |
|
300 | 325 | function formatDuration(seconds) { |
|
0 commit comments