Update script.js
Browse files
script.js
CHANGED
|
@@ -168,24 +168,50 @@ function updateYouTubeEmbed(timestampSeconds) {
|
|
| 168 |
fullscreenYoutubeIframeMobile.src = embedUrl;
|
| 169 |
}
|
| 170 |
|
| 171 |
-
// Render step indicators
|
| 172 |
function renderStepIndicators(containerId, currentStep, onClick) {
|
| 173 |
const container = document.getElementById(containerId);
|
| 174 |
container.innerHTML = '';
|
| 175 |
|
| 176 |
const groupStart = Math.floor((currentStep - 1) / 10) * 10 + 1;
|
|
|
|
|
|
|
|
|
|
| 177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
for (let i = 0; i < 10; i++) {
|
| 179 |
const stepNum = groupStart + i;
|
| 180 |
if (stepNum > TOTAL_STEPS) break;
|
| 181 |
|
| 182 |
const isActive = stepNum === currentStep;
|
| 183 |
const button = document.createElement('button');
|
| 184 |
-
button.className = `step-indicator ${isActive ? 'step-indicator-active' : '
|
|
|
|
| 185 |
button.setAttribute('aria-label', `Go to step ${stepNum}`);
|
| 186 |
button.addEventListener('click', () => onClick(stepNum));
|
| 187 |
container.appendChild(button);
|
| 188 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
}
|
| 190 |
|
| 191 |
// Update UI
|
|
|
|
| 168 |
fullscreenYoutubeIframeMobile.src = embedUrl;
|
| 169 |
}
|
| 170 |
|
| 171 |
+
// Render step indicators with pagination
|
| 172 |
function renderStepIndicators(containerId, currentStep, onClick) {
|
| 173 |
const container = document.getElementById(containerId);
|
| 174 |
container.innerHTML = '';
|
| 175 |
|
| 176 |
const groupStart = Math.floor((currentStep - 1) / 10) * 10 + 1;
|
| 177 |
+
const groupEnd = Math.min(groupStart + 9, TOTAL_STEPS);
|
| 178 |
+
const canGoPrevGroup = groupStart > 1;
|
| 179 |
+
const canGoNextGroup = groupEnd < TOTAL_STEPS;
|
| 180 |
|
| 181 |
+
// Previous group button
|
| 182 |
+
if (canGoPrevGroup) {
|
| 183 |
+
const prevGroupBtn = document.createElement('button');
|
| 184 |
+
prevGroupBtn.className = 'step-indicator-nav';
|
| 185 |
+
prevGroupBtn.innerHTML = '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>';
|
| 186 |
+
prevGroupBtn.setAttribute('aria-label', 'Previous group');
|
| 187 |
+
prevGroupBtn.addEventListener('click', () => onClick(groupStart - 1));
|
| 188 |
+
container.appendChild(prevGroupBtn);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
// Step number buttons
|
| 192 |
for (let i = 0; i < 10; i++) {
|
| 193 |
const stepNum = groupStart + i;
|
| 194 |
if (stepNum > TOTAL_STEPS) break;
|
| 195 |
|
| 196 |
const isActive = stepNum === currentStep;
|
| 197 |
const button = document.createElement('button');
|
| 198 |
+
button.className = `step-indicator-num ${isActive ? 'step-indicator-num-active' : ''}`;
|
| 199 |
+
button.textContent = stepNum;
|
| 200 |
button.setAttribute('aria-label', `Go to step ${stepNum}`);
|
| 201 |
button.addEventListener('click', () => onClick(stepNum));
|
| 202 |
container.appendChild(button);
|
| 203 |
}
|
| 204 |
+
|
| 205 |
+
// Next group button
|
| 206 |
+
if (canGoNextGroup) {
|
| 207 |
+
const nextGroupBtn = document.createElement('button');
|
| 208 |
+
nextGroupBtn.className = 'step-indicator-nav';
|
| 209 |
+
nextGroupBtn.innerHTML = '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>';
|
| 210 |
+
nextGroupBtn.setAttribute('aria-label', 'Next group');
|
| 211 |
+
nextGroupBtn.addEventListener('click', () => onClick(groupEnd + 1));
|
| 212 |
+
container.appendChild(nextGroupBtn);
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
}
|
| 216 |
|
| 217 |
// Update UI
|