Skip to content

Commit db70dfe

Browse files
committed
Add Pyodide version selection dropdown to REPL
Adds a version picker in the header that lets users choose which Pyodide version to load (v0.24.1 through v0.27.5). The selected version is persisted via the ?v= URL parameter, and changing versions reloads the page with the new selection. https://claude.ai/code/session_01G5zh3gpcGirvwjG1qeU9LQ
1 parent d771a23 commit db70dfe

1 file changed

Lines changed: 67 additions & 3 deletions

File tree

pyodide-repl.html

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,38 @@
4040
border-bottom: 1px solid var(--border);
4141
background: var(--bg);
4242
}
43+
#header-top {
44+
display: flex;
45+
align-items: center;
46+
justify-content: space-between;
47+
gap: 12px;
48+
}
4349
#header h1 {
4450
font-size: 16px;
4551
font-weight: 600;
4652
color: var(--accent);
4753
}
54+
#version-picker {
55+
display: flex;
56+
align-items: center;
57+
gap: 6px;
58+
font-size: 12px;
59+
color: var(--muted);
60+
}
61+
#version-select {
62+
background: var(--surface);
63+
color: var(--text);
64+
border: 1px solid var(--border);
65+
border-radius: 4px;
66+
padding: 4px 6px;
67+
font-family: var(--mono);
68+
font-size: 12px;
69+
cursor: pointer;
70+
}
71+
#version-select:focus {
72+
outline: none;
73+
border-color: var(--accent);
74+
}
4875
#header .subtitle {
4976
font-size: 12px;
5077
color: var(--muted);
@@ -198,7 +225,28 @@
198225

199226
<div id="scroll-container">
200227
<div id="header">
201-
<h1>Pyodide REPL</h1>
228+
<div id="header-top">
229+
<h1>Pyodide REPL</h1>
230+
<div id="version-picker">
231+
<label for="version-select">Pyodide</label>
232+
<select id="version-select">
233+
<option value="0.27.5">v0.27.5</option>
234+
<option value="0.27.4">v0.27.4</option>
235+
<option value="0.27.3">v0.27.3</option>
236+
<option value="0.27.2">v0.27.2</option>
237+
<option value="0.27.1">v0.27.1</option>
238+
<option value="0.27.0">v0.27.0</option>
239+
<option value="0.26.4">v0.26.4</option>
240+
<option value="0.26.3">v0.26.3</option>
241+
<option value="0.26.2">v0.26.2</option>
242+
<option value="0.26.1">v0.26.1</option>
243+
<option value="0.26.0">v0.26.0</option>
244+
<option value="0.25.1" selected>v0.25.1</option>
245+
<option value="0.25.0">v0.25.0</option>
246+
<option value="0.24.1">v0.24.1</option>
247+
</select>
248+
</div>
249+
</div>
202250
<div class="subtitle">Python in the browser &mdash; mobile friendly</div>
203251
</div>
204252

@@ -232,6 +280,22 @@ <h1>Pyodide REPL</h1>
232280
const promptLabel = document.getElementById('prompt-label');
233281
const loadingOverlay = document.getElementById('loading-overlay');
234282
const loadingText = document.getElementById('loading-text');
283+
const versionSelect = document.getElementById('version-select');
284+
285+
// Version selection from URL parameter
286+
const urlParams = new URLSearchParams(window.location.search);
287+
const urlVersion = urlParams.get('v');
288+
if (urlVersion && versionSelect.querySelector(`option[value="${CSS.escape(urlVersion)}"]`)) {
289+
versionSelect.value = urlVersion;
290+
}
291+
const selectedVersion = versionSelect.value;
292+
293+
versionSelect.addEventListener('change', () => {
294+
const newVersion = versionSelect.value;
295+
const url = new URL(window.location);
296+
url.searchParams.set('v', newVersion);
297+
window.location.href = url.toString();
298+
});
235299

236300
let pyodide = null;
237301
let pyconsole = null;
@@ -446,8 +510,8 @@ <h1>Pyodide REPL</h1>
446510
// Initialize
447511
async function init() {
448512
try {
449-
loadingText.textContent = 'Loading Pyodide runtime...';
450-
const indexURL = 'https://cdn.jsdelivr.net/pyodide/v0.25.1/full/';
513+
loadingText.textContent = `Loading Pyodide v${selectedVersion}...`;
514+
const indexURL = `https://cdn.jsdelivr.net/pyodide/v${selectedVersion}/full/`;
451515
const { loadPyodide } = await import(indexURL + 'pyodide.mjs');
452516

453517
loadingText.textContent = 'Initializing Python...';

0 commit comments

Comments
 (0)