|
40 | 40 | border-bottom: 1px solid var(--border); |
41 | 41 | background: var(--bg); |
42 | 42 | } |
| 43 | + #header-top { |
| 44 | + display: flex; |
| 45 | + align-items: center; |
| 46 | + justify-content: space-between; |
| 47 | + gap: 12px; |
| 48 | + } |
43 | 49 | #header h1 { |
44 | 50 | font-size: 16px; |
45 | 51 | font-weight: 600; |
46 | 52 | color: var(--accent); |
47 | 53 | } |
| 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 | + } |
48 | 75 | #header .subtitle { |
49 | 76 | font-size: 12px; |
50 | 77 | color: var(--muted); |
|
198 | 225 |
|
199 | 226 | <div id="scroll-container"> |
200 | 227 | <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> |
202 | 250 | <div class="subtitle">Python in the browser — mobile friendly</div> |
203 | 251 | </div> |
204 | 252 |
|
@@ -232,6 +280,22 @@ <h1>Pyodide REPL</h1> |
232 | 280 | const promptLabel = document.getElementById('prompt-label'); |
233 | 281 | const loadingOverlay = document.getElementById('loading-overlay'); |
234 | 282 | 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 | + }); |
235 | 299 |
|
236 | 300 | let pyodide = null; |
237 | 301 | let pyconsole = null; |
@@ -446,8 +510,8 @@ <h1>Pyodide REPL</h1> |
446 | 510 | // Initialize |
447 | 511 | async function init() { |
448 | 512 | 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/`; |
451 | 515 | const { loadPyodide } = await import(indexURL + 'pyodide.mjs'); |
452 | 516 |
|
453 | 517 | loadingText.textContent = 'Initializing Python...'; |
|
0 commit comments