Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions docs/step.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@
const GITHUB_RAW_BASE = isLocal
? '../workshop/'
: 'https://raw.githubusercontent.com/copilot-dev-days/agent-lab-python/main/workshop/';
const CHECKBOX_STORAGE_KEY = 'agent-lab-checkboxes-v1';
let checkboxSaveTimeout;

// Get current step from URL
function getCurrentStepId() {
Expand All @@ -232,6 +234,54 @@
return steps.findIndex(s => s.id === stepId);
}

function readCheckboxState() {
try {
return JSON.parse(localStorage.getItem(CHECKBOX_STORAGE_KEY) || '{}');
} catch {
return {};
}
}

function writeCheckboxState(state) {
try {
localStorage.setItem(CHECKBOX_STORAGE_KEY, JSON.stringify(state));
} catch {
// Ignore storage failures (private mode / blocked storage)
}
}

function writeCheckboxStateDebounced(state) {
clearTimeout(checkboxSaveTimeout);
checkboxSaveTimeout = setTimeout(() => writeCheckboxState(state), 100);
}

function initializeTaskListCheckboxes(stepId) {
const container = document.getElementById('markdown-content');
if (!container) return;
const checkboxes = container.querySelectorAll('input[type="checkbox"]');
if (checkboxes.length === 0) return;

const allState = readCheckboxState();
if (!Array.isArray(allState[stepId])) {
allState[stepId] = [];
}
const stepState = allState[stepId];

checkboxes.forEach((checkbox, index) => {
checkbox.disabled = false;

if (typeof stepState[index] === 'boolean') {
checkbox.checked = stepState[index];
}

checkbox.addEventListener('change', () => {
stepState[index] = checkbox.checked;
allState[stepId] = stepState;
writeCheckboxStateDebounced(allState);
});
});
}

// Build sidebar navigation
function buildSidebar() {
const nav = document.getElementById('stepNav');
Expand Down Expand Up @@ -339,6 +389,7 @@
});

document.getElementById('markdown-content').innerHTML = marked.parse(md);
initializeTaskListCheckboxes(step.id);

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