|
|
|
|
|
let currentStep = 1; |
|
|
const totalSteps = 51; |
|
|
|
|
|
|
|
|
const availableImages = { |
|
|
1: 'assets/p9.jpg', |
|
|
2: 'assets/p10.jpg' |
|
|
}; |
|
|
|
|
|
|
|
|
const stepDisplay = document.getElementById('stepDisplay'); |
|
|
const stepImage = document.getElementById('stepImage'); |
|
|
const placeholderText = document.getElementById('placeholderText'); |
|
|
const placeholderNumber = document.getElementById('placeholderNumber'); |
|
|
const placeholderStep = document.getElementById('placeholderStep'); |
|
|
const prevBtn = document.getElementById('prevBtn'); |
|
|
const nextBtn = document.getElementById('nextBtn'); |
|
|
const progressFill = document.getElementById('progressFill'); |
|
|
const indicatorsContainer = document.getElementById('indicators'); |
|
|
|
|
|
|
|
|
function init() { |
|
|
createIndicators(); |
|
|
updateDisplay(); |
|
|
} |
|
|
|
|
|
|
|
|
function createIndicators() { |
|
|
const indicatorsToShow = Math.min(totalSteps, 10); |
|
|
|
|
|
for (let i = 0; i < indicatorsToShow; i++) { |
|
|
const button = document.createElement('button'); |
|
|
button.className = 'indicator'; |
|
|
button.setAttribute('aria-label', `Go to step ${i + 1}`); |
|
|
button.addEventListener('click', () => { |
|
|
const targetStep = Math.floor((currentStep - 1) / 10) * 10 + i + 1; |
|
|
if (targetStep <= totalSteps) { |
|
|
goToStep(targetStep); |
|
|
} |
|
|
}); |
|
|
indicatorsContainer.appendChild(button); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function updateIndicators() { |
|
|
const indicators = indicatorsContainer.children; |
|
|
const startStep = Math.floor((currentStep - 1) / 10) * 10 + 1; |
|
|
|
|
|
Array.from(indicators).forEach((indicator, i) => { |
|
|
const step = startStep + i; |
|
|
if (step > totalSteps) { |
|
|
indicator.style.display = 'none'; |
|
|
} else { |
|
|
indicator.style.display = 'block'; |
|
|
indicator.classList.toggle('active', step === currentStep); |
|
|
} |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
function updateDisplay() { |
|
|
|
|
|
stepDisplay.textContent = `Step ${currentStep}/${totalSteps}`; |
|
|
|
|
|
|
|
|
if (availableImages[currentStep]) { |
|
|
stepImage.src = availableImages[currentStep]; |
|
|
stepImage.alt = `Assembly step ${currentStep}`; |
|
|
stepImage.style.display = 'block'; |
|
|
placeholderText.style.display = 'none'; |
|
|
} else { |
|
|
stepImage.style.display = 'none'; |
|
|
placeholderText.style.display = 'block'; |
|
|
placeholderNumber.textContent = currentStep; |
|
|
placeholderStep.textContent = currentStep; |
|
|
} |
|
|
|
|
|
|
|
|
prevBtn.disabled = currentStep === 1; |
|
|
nextBtn.disabled = currentStep === totalSteps; |
|
|
|
|
|
|
|
|
const progress = (currentStep / totalSteps) * 100; |
|
|
progressFill.style.width = `${progress}%`; |
|
|
|
|
|
|
|
|
updateIndicators(); |
|
|
} |
|
|
|
|
|
|
|
|
function goToStep(step) { |
|
|
if (step >= 1 && step <= totalSteps) { |
|
|
currentStep = step; |
|
|
updateDisplay(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function nextStep() { |
|
|
if (currentStep < totalSteps) { |
|
|
currentStep++; |
|
|
updateDisplay(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function prevStep() { |
|
|
if (currentStep > 1) { |
|
|
currentStep--; |
|
|
updateDisplay(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
nextBtn.addEventListener('click', nextStep); |
|
|
prevBtn.addEventListener('click', prevStep); |
|
|
|
|
|
|
|
|
document.addEventListener('keydown', (e) => { |
|
|
if (e.key === 'ArrowRight') { |
|
|
nextStep(); |
|
|
} else if (e.key === 'ArrowLeft') { |
|
|
prevStep(); |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
init(); |
|
|
|