From 94342a3a626439a3a191313cb2c102bb37644d09 Mon Sep 17 00:00:00 2001 From: dschlueter Date: Mon, 6 Apr 2026 17:35:14 +0200 Subject: [PATCH] Fix: Remove duplicate function declarations (tick, finishAnimation, stopTimer, readUrlState, writeUrlState) --- sorting_visualization.html | 61 ++------------------------------------ 1 file changed, 2 insertions(+), 59 deletions(-) diff --git a/sorting_visualization.html b/sorting_visualization.html index 0eda33e..467600e 100644 --- a/sorting_visualization.html +++ b/sorting_visualization.html @@ -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) // ================================================================