Skip to content

Commit aae903c

Browse files
Merge pull request #3 from copilot-dev-days/copilot/make-checkboxes-clickable
Enable interactive checklist checkboxes in deployed workshop pages
2 parents e90f6d5 + b025ccd commit aae903c

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

docs/step.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,41 @@
278278
}
279279
}
280280

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+
281316
// Process markdown - clean up navigation links and fix paths
282317
function processMarkdown(md) {
283318
// Remove the header navigation bar (we have our own sidebar)
@@ -337,6 +372,7 @@
337372
});
338373

339374
document.getElementById('markdown-content').innerHTML = marked.parse(md);
375+
enableTaskListCheckboxes(step.id);
340376

341377
// If this is the completion page, add confetti!
342378
if (step.id === '05-complete') {

0 commit comments

Comments
 (0)