|
278 | 278 | } |
279 | 279 | } |
280 | 280 |
|
| 281 | + // Enable clickable task-list checkboxes and persist by step |
| 282 | + function enableTaskListCheckboxes(stepId) { |
| 283 | + const checkboxes = Array.from(document.querySelectorAll('#markdown-content input[type="checkbox"]')); |
| 284 | + if (!checkboxes.length) return; |
| 285 | + |
| 286 | + const storageKey = `lab-checklist:${stepId}`; |
| 287 | + let savedStates = null; |
| 288 | + |
| 289 | + try { |
| 290 | + const raw = localStorage.getItem(storageKey); |
| 291 | + if (raw) { |
| 292 | + savedStates = JSON.parse(raw); |
| 293 | + } |
| 294 | + } catch (e) { |
| 295 | + savedStates = null; |
| 296 | + } |
| 297 | + |
| 298 | + checkboxes.forEach((checkbox, index) => { |
| 299 | + checkbox.removeAttribute('disabled'); |
| 300 | + |
| 301 | + if (Array.isArray(savedStates) && typeof savedStates[index] === 'boolean') { |
| 302 | + checkbox.checked = savedStates[index]; |
| 303 | + } |
| 304 | + |
| 305 | + checkbox.addEventListener('change', () => { |
| 306 | + const currentStates = checkboxes.map(cb => cb.checked); |
| 307 | + try { |
| 308 | + localStorage.setItem(storageKey, JSON.stringify(currentStates)); |
| 309 | + } catch (e) { |
| 310 | + // Ignore storage failures (private browsing, disabled storage, etc.) |
| 311 | + } |
| 312 | + }); |
| 313 | + }); |
| 314 | + } |
| 315 | + |
281 | 316 | // Process markdown - clean up navigation links and fix paths |
282 | 317 | function processMarkdown(md) { |
283 | 318 | // Remove the header navigation bar (we have our own sidebar) |
|
337 | 372 | }); |
338 | 373 |
|
339 | 374 | document.getElementById('markdown-content').innerHTML = marked.parse(md); |
| 375 | + enableTaskListCheckboxes(step.id); |
340 | 376 |
|
341 | 377 | // If this is the completion page, add confetti! |
342 | 378 | if (step.id === '05-complete') { |
|
0 commit comments