-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.html
More file actions
206 lines (183 loc) · 9.07 KB
/
Copy pathsearch.html
File metadata and controls
206 lines (183 loc) · 9.07 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
<!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 — Search Lab with linear, binary, jump, interpolation, exponential, ternary, and Fibonacci search, teaching mode, and race." />
<meta name="theme-color" content="#0b1220" />
<title>Algo Lab — Search Visualizer</title>
<link rel="manifest" href="manifest.json" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<a class="skip-link" href="#workspace">Skip to lab</a>
<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">Search Algorithm Visualizer</p>
</div>
</div>
<nav class="lab-switcher" aria-label="Choose a lab">
<a class="lab-pill" href="index.html">Sort Lab</a>
<a class="lab-pill" href="pathfinding.html">Path Lab</a>
<a class="lab-pill is-active" href="search.html" aria-current="page">Search 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>
<label class="toggle-pill" title="Sound effects on probe">
<input type="checkbox" id="soundToggle" aria-label="Toggle sound" />
<span>🔊 Sound</span>
</label>
<button id="cheatSheetBtn" class="icon-btn" type="button" title="Keyboard shortcuts (?)" aria-label="Keyboard shortcuts">?</button>
<button id="themeToggle" class="icon-btn" aria-label="Toggle dark mode">🌙</button>
</div>
</header>
<div class="workspace" id="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="linear">Linear Search</option>
<option value="binary" selected>Binary Search</option>
<option value="jump">Jump Search</option>
<option value="interpolation">Interpolation Search</option>
<option value="exponential">Exponential Search</option>
<option value="ternary">Ternary Search</option>
<option value="fibonacci">Fibonacci Search</option>
</select>
</div>
<div class="field race-field">
<label class="checkbox-row">
<input type="checkbox" id="raceMode" />
<span>Race linear vs binary</span>
</label>
</div>
<div class="field">
<label for="dataset">Dataset</label>
<select id="dataset">
<option value="random-sorted">Random Sorted</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">16</span></label>
<input type="range" id="size" min="5" max="40" value="16" />
</div>
<div class="field">
<label for="target">Target value</label>
<input type="number" id="target" value="42" />
</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="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>
<p class="shortcut-hint">Space pause · S start · G generate · R reset · ? shortcuts</p>
</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">
<h2 class="panel-title">Run History</h2>
<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>
<p id="sortedNote" class="search-note" hidden>This algorithm needs a sorted array. The current dataset was sorted automatically.</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 id="searchGrid" class="search-grid" role="list" aria-label="Search array"></div>
</section>
<section class="viz-pane hidden" id="paneSecondary">
<div class="pane-header">
<h3 id="paneSecondaryLabel">Binary Search</h3>
<div id="metricsSecondary" class="metrics-strip"></div>
</div>
<div id="searchGridRace" class="search-grid" role="list" aria-label="Search array race pane"></div>
</section>
</div>
<section class="legend" id="legend">
<div class="legend-item"><span class="swatch search-default"></span> Unexamined</div>
<div class="legend-item"><span class="swatch search-probe"></span> Current probe</div>
<div class="legend-item"><span class="swatch search-lo"></span> Low bound</div>
<div class="legend-item"><span class="swatch search-hi"></span> High bound</div>
<div class="legend-item"><span class="swatch search-found"></span> Found</div>
<div class="legend-item"><span class="swatch search-elim"></span> Eliminated</div>
</section>
</main>
</div>
</div>
<dialog id="cheatSheet" class="cheat-sheet" aria-labelledby="cheatSheetTitle">
<div class="cheat-sheet-header">
<h2 id="cheatSheetTitle">Keyboard shortcuts</h2>
<button type="button" id="cheatSheetClose" class="icon-btn" aria-label="Close cheat sheet">×</button>
</div>
<ul class="cheat-sheet-list">
<li><kbd>Space</kbd> Pause / resume</li>
<li><kbd>S</kbd> Start search</li>
<li><kbd>G</kbd> Generate array</li>
<li><kbd>R</kbd> Reset / generate</li>
<li><kbd>?</kbd> Toggle this cheat sheet</li>
</ul>
</dialog>
<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="search-core.js"></script>
<script src="search.js"></script>
</body>
</html>