-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
269 lines (241 loc) · 12.6 KB
/
Copy pathindex.html
File metadata and controls
269 lines (241 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Algo Lab — interactive sorting visualizer with 10 algorithms, race mode, teaching mode, tournaments, plus a pathfinding lab." />
<meta name="theme-color" content="#0b1220" />
<title>Algo Lab — Sorting Visualizer</title>
<link rel="manifest" href="manifest.json" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="app-shell">
<header class="topbar">
<div class="topbar-start">
<div class="brand">
<span class="brand-mark" aria-hidden="true">⚗</span>
<div>
<h1>Algo Lab</h1>
<p class="brand-sub">Sorting Algorithm Visualizer</p>
</div>
</div>
<nav class="lab-switcher" aria-label="Choose a lab">
<a class="lab-pill is-active" href="index.html" aria-current="page">Sort Lab</a>
<a class="lab-pill" href="pathfinding.html">Path Lab</a>
</nav>
</div>
<div class="topbar-actions">
<button id="shareUrlBtn" class="btn btn-ghost btn-sm" type="button" title="Copy shareable URL">🔗 Share</button>
<button id="presentationBtn" class="btn btn-ghost btn-sm" type="button" title="Presentation mode (Esc to exit)">🖥 Present</button>
<label class="toggle-pill" title="Sound effects on compare/swap">
<input type="checkbox" id="soundToggle" aria-label="Toggle sound" />
<span>🔊 Sound</span>
</label>
<button id="themeToggle" class="icon-btn" aria-label="Toggle dark mode">🌙</button>
</div>
</header>
<div class="workspace">
<aside class="sidebar">
<section class="panel">
<h2 class="panel-title">Controls</h2>
<div class="field">
<label for="algorithm">Algorithm</label>
<select id="algorithm">
<option value="bubble">Bubble Sort</option>
<option value="selection">Selection Sort</option>
<option value="insertion">Insertion Sort</option>
<option value="merge">Merge Sort</option>
<option value="quick">Quick Sort</option>
<option value="heap">Heap Sort</option>
<option value="shell">Shell Sort</option>
<option value="radix">Radix Sort</option>
<option value="counting">Counting Sort</option>
<option value="cocktail">Cocktail Shaker Sort</option>
</select>
</div>
<div class="field race-field">
<label class="checkbox-row">
<input type="checkbox" id="raceMode" />
<span>Algorithm Race (dual pane)</span>
</label>
<select id="algorithmRace" disabled>
<option value="bubble">Bubble Sort</option>
<option value="selection">Selection Sort</option>
<option value="insertion">Insertion Sort</option>
<option value="merge">Merge Sort</option>
<option value="quick" selected>Quick Sort</option>
<option value="heap">Heap Sort</option>
<option value="shell">Shell Sort</option>
<option value="radix">Radix Sort</option>
<option value="counting">Counting Sort</option>
<option value="cocktail">Cocktail Shaker Sort</option>
</select>
</div>
<div class="field">
<label for="dataset">Dataset</label>
<select id="dataset">
<option value="random">Random</option>
<option value="sorted">Sorted</option>
<option value="nearly-sorted">Nearly Sorted</option>
<option value="reversed">Reversed</option>
<option value="few-unique">Few Unique</option>
<option value="sawtooth">Sawtooth</option>
<option value="custom">Custom Input</option>
</select>
</div>
<div class="field" id="customArrayField" hidden>
<label for="customArray">Custom Array</label>
<textarea id="customArray" rows="3" placeholder="Comma-separated: 5,3,8,1,9 or JSON: [5,3,8,1,9]"></textarea>
<button id="applyCustomBtn" type="button" class="btn btn-secondary btn-sm">Apply Custom Array</button>
<p id="customArrayError" class="field-error" role="alert" hidden></p>
</div>
<div class="field">
<label for="size">Array Size: <span id="sizeValue">50</span></label>
<input type="range" id="size" min="10" max="120" value="50" />
</div>
<div class="field">
<label for="speed">Speed: <span id="speedValue">50</span></label>
<input type="range" id="speed" min="1" max="100" value="50" />
</div>
<div class="field">
<label class="checkbox-row">
<input type="checkbox" id="stepMode" />
<span>Step Mode (manual advance)</span>
</label>
</div>
<div class="field">
<label class="checkbox-row">
<input type="checkbox" id="teachingMode" />
<span>Teaching Mode (narrated steps)</span>
</label>
</div>
<div class="field">
<label class="checkbox-row">
<input type="checkbox" id="quizMode" />
<span>Quiz Mode (guess the algorithm)</span>
</label>
<p id="quizScore" class="quiz-score" aria-live="polite">Score: 0 / 0</p>
</div>
<div class="btn-grid">
<button id="generateBtn" class="btn btn-secondary" title="Shortcut: G">Generate</button>
<button id="startBtn" class="btn btn-primary" title="Shortcut: S">Start</button>
<button id="pauseBtn" class="btn btn-secondary" disabled title="Shortcut: Space">Pause</button>
<button id="stopBtn" class="btn btn-danger" disabled>Stop</button>
<button id="nextStepBtn" class="btn btn-accent" disabled>Next Step</button>
<button id="resetBtn" class="btn btn-secondary" title="Shortcut: R">Reset</button>
</div>
<button id="tournamentBtn" type="button" class="btn btn-accent btn-full" title="Run all 10 algorithms on current data">🏆 Benchmark Tournament</button>
<p class="shortcut-hint">Space pause · S start · G generate · R reset · Esc exit present</p>
</section>
<section class="panel" id="recommenderPanel">
<h2 class="panel-title">Algorithm Recommender</h2>
<p class="panel-sub">Best fit for the current dataset</p>
<div id="recommenderContent" class="recommender-content" aria-live="polite"></div>
</section>
<section class="panel" id="profilePanel" aria-live="polite"></section>
<section class="panel" id="learningCardsPanel">
<h2 class="panel-title">Learning Cards</h2>
<p class="panel-sub">Tap to flip — trivia & real-world use cases</p>
<div id="learningCard" class="learning-card" tabindex="0" role="button" aria-label="Flip learning card">
<div class="learning-card-inner">
<div class="learning-card-front">
<span class="learning-card-label">Did you know?</span>
<p id="learningTrivia" class="learning-card-text"></p>
</div>
<div class="learning-card-back">
<span class="learning-card-label">Use case</span>
<p id="learningUseCase" class="learning-card-text"></p>
</div>
</div>
</div>
</section>
<section class="panel" id="quizPanel" hidden>
<h2 class="panel-title">Quiz — Which algorithm was that?</h2>
<div id="quizGuessGrid" class="quiz-guess-grid"></div>
<p id="quizFeedback" class="quiz-feedback" role="status" aria-live="polite"></p>
</section>
<section class="panel" id="tournamentPanel" hidden>
<h2 class="panel-title">Tournament Leaderboard</h2>
<div id="leaderboard" class="leaderboard-wrap"></div>
</section>
<section class="panel" id="comparisonPanel" hidden>
<h2 class="panel-title">Comparison Matrix</h2>
<p class="panel-sub">Theoretical vs actual performance (last tournament)</p>
<div id="comparisonMatrix" class="matrix-wrap"></div>
</section>
<section class="panel">
<div class="panel-header-row">
<h2 class="panel-title">Run History</h2>
<div class="panel-actions">
<button id="exportCsvBtn" class="btn btn-ghost btn-sm">Export CSV</button>
<button id="copySummaryBtn" class="btn btn-ghost btn-sm">Copy Summary</button>
</div>
</div>
<ul id="historyList" class="history-list"></ul>
</section>
</aside>
<main class="main-stage">
<p id="statusText" class="status-bar" aria-live="polite" role="status">Ready</p>
<section id="teachingPanel" class="teaching-panel hidden" aria-labelledby="teachingTitle">
<h3 id="teachingTitle" class="teaching-title">Teaching Mode</h3>
<p id="teachingText" class="teaching-text" aria-live="assertive" aria-atomic="true">Enable Teaching Mode to see step-by-step explanations.</p>
</section>
<div class="viz-grid" id="vizGrid">
<section class="viz-pane" id="panePrimary">
<div class="pane-header">
<h3 id="panePrimaryLabel">Primary</h3>
<div id="metricsPrimary" class="metrics-strip"></div>
</div>
<div class="viz-body">
<div class="visualizer" id="visualizer" role="img" aria-label="Sorting visualization primary pane"></div>
<div id="heatmapPrimary" class="heatmap-strip" aria-label="Per-index access frequency heatmap"></div>
</div>
<div id="countingArrayPanel" class="counting-panel hidden" aria-label="Counting sort counting array">
<span class="counting-panel-label">Counting array</span>
<div id="countingArrayDisplay" class="counting-array"></div>
</div>
<div class="ops-chart-wrap">
<span class="ops-chart-label">Operations over time</span>
<canvas id="opsChart" class="ops-chart" width="600" height="56" aria-label="Cumulative operations sparkline during current run"></canvas>
</div>
</section>
<section class="viz-pane hidden" id="paneSecondary">
<div class="pane-header">
<h3>Race</h3>
<div id="metricsSecondary" class="metrics-strip"></div>
</div>
<div class="viz-body">
<div class="visualizer" id="visualizerRace" role="img" aria-label="Sorting visualization race pane"></div>
<div id="heatmapSecondary" class="heatmap-strip" aria-label="Per-index access frequency heatmap race pane"></div>
</div>
</section>
</div>
<section class="legend" id="legend">
<div class="legend-item"><span class="swatch default"></span> Unsorted</div>
<div class="legend-item"><span class="swatch compare"></span> Comparing</div>
<div class="legend-item"><span class="swatch swap"></span> Swapping</div>
<div class="legend-item"><span class="swatch write"></span> Writing</div>
<div class="legend-item"><span class="swatch pivot"></span> Pivot (Quick Sort)</div>
<div class="legend-item"><span class="swatch digit"></span> Digit pass (Radix)</div>
<div class="legend-item"><span class="swatch bucket"></span> Bucket (Counting)</div>
<div class="legend-item"><span class="swatch gap"></span> Gap pair (Shell)</div>
<div class="legend-item"><span class="swatch sorted"></span> Sorted</div>
</section>
</main>
</div>
</div>
<div id="presentationOverlay" class="presentation-overlay hidden" role="dialog" aria-modal="true" aria-label="Presentation mode">
<div class="presentation-hud">
<span id="presentationAlgo" class="presentation-algo">Algorithm</span>
<span id="presentationMetrics" class="presentation-metrics"></span>
<button id="presentationExitBtn" class="btn btn-ghost btn-sm" type="button">Esc — Exit</button>
</div>
<div id="presentationVisualizer" class="presentation-visualizer"></div>
<div id="presentationHeatmap" class="presentation-heatmap"></div>
</div>
<div id="toast" class="toast" role="status" aria-live="polite"></div>
<div id="a11yAnnouncer" class="sr-only" aria-live="assertive" aria-atomic="true"></div>
<script src="script.js"></script>
</body>
</html>