Fix: Remove duplicate function declarations (tick, finishAnimation, stopTimer, readUrlState, writeUrlState)
This commit is contained in:
parent
b8f6889cb4
commit
94342a3a62
1 changed files with 2 additions and 59 deletions
|
|
@ -2748,47 +2748,12 @@ function finishAnimation() {
|
|||
updateButtonStates();
|
||||
}
|
||||
|
||||
function stopTimer() {
|
||||
if (animTimer !== null) { clearInterval(animTimer); animTimer = null; }
|
||||
}
|
||||
}
|
||||
|
||||
// Start timing on first tick
|
||||
if (startTime === 0) startTime = performance.now();
|
||||
animTimer = window.setInterval(tick, delay);
|
||||
}
|
||||
|
||||
function tick() {
|
||||
if (stepIndex >= steps.length) { finishAnimation(); return; }
|
||||
renderStep(steps[stepIndex], stepIndex + 1);
|
||||
stepIndex++;
|
||||
// Update elapsed time display
|
||||
elapsedMs = Math.round(performance.now() - startTime);
|
||||
$statTime.textContent = elapsedMs + ' ms';
|
||||
if (stepIndex >= steps.length) finishAnimation();
|
||||
}
|
||||
|
||||
function finishAnimation() {
|
||||
if (animTimer !== null) { clearInterval(animTimer); animTimer = null; }
|
||||
isRunning = false;
|
||||
isPaused = false;
|
||||
const last = steps[steps.length - 1];
|
||||
if (last) {
|
||||
drawBars(last.array, {}, true);
|
||||
setStats(last.compares, last.swaps, last.moves, steps.length);
|
||||
}
|
||||
elapsedMs = Math.round(performance.now() - startTime);
|
||||
$statTime.textContent = elapsedMs + ' ms';
|
||||
updateProgress(steps.length, steps.length);
|
||||
$phaseLabel.innerHTML = ' ';
|
||||
$stepExplanation.textContent = 'Sortierung abgeschlossen \u2713';
|
||||
updateButtonStates();
|
||||
}
|
||||
|
||||
function stopTimer() {
|
||||
if (animTimer !== null) { clearInterval(animTimer); animTimer = null; }
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Reset
|
||||
// ================================================================
|
||||
// Reset
|
||||
// ================================================================
|
||||
|
|
@ -3099,28 +3064,6 @@ function writeUrlState() {
|
|||
window.history.replaceState(null, '', url);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// URL State Persistence
|
||||
// ================================================================
|
||||
|
||||
function readUrlState() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
if (params.has('algo')) $algoSelect.value = params.get('algo');
|
||||
if (params.has('preset')) $presetSelect.value = params.get('preset');
|
||||
if (params.has('size')) $sizeSlider.value = Math.max(5, Math.min(200, parseInt(params.get('size'), 10) || 50));
|
||||
if (params.has('speed')) $speedSlider.value = Math.max(1, Math.min(100, parseInt(params.get('speed'), 10) || 50));
|
||||
}
|
||||
|
||||
function writeUrlState() {
|
||||
const params = new URLSearchParams();
|
||||
params.set('algo', $algoSelect.value);
|
||||
params.set('preset', $presetSelect.value);
|
||||
params.set('size', $sizeSlider.value);
|
||||
params.set('speed', $speedSlider.value);
|
||||
const url = window.location.pathname + '?' + params.toString();
|
||||
window.history.replaceState(null, '', url);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Window Resize (ResizeObserver + fallback)
|
||||
// ================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue