diff --git a/.gamification.json b/.gamification.json index 8ef0d9a..d50ed80 100644 --- a/.gamification.json +++ b/.gamification.json @@ -10,5 +10,5 @@ "streak_tage": 1, "letzter_aktiver_tag": "2026-08-29", "historie": [], - "zuletzt_aktualisiert": "2026-08-29T15:40:02.637013" + "zuletzt_aktualisiert": "2026-08-29T15:41:25.557977" } \ No newline at end of file diff --git a/assets/gamification_data.js b/assets/gamification_data.js index d46c4b7..bd7d817 100644 --- a/assets/gamification_data.js +++ b/assets/gamification_data.js @@ -11,7 +11,7 @@ window.GAMIFICATION_DATA = { "streak_tage": 1, "letzter_aktiver_tag": "2026-08-29", "historie": [], - "zuletzt_aktualisiert": "2026-08-29T15:40:02.637013" + "zuletzt_aktualisiert": "2026-08-29T15:41:25.557977" }; window.GAMIFICATION_BADGES_KATALOG = { "rechenkonegin": { diff --git a/assets/runner.js b/assets/runner.js new file mode 100644 index 0000000..a557835 --- /dev/null +++ b/assets/runner.js @@ -0,0 +1,134 @@ +/** + * ⚡ ZERO-SETUP IN-BROWSER PYTHON RUNNER (Pyodide / WebAssembly) ⚡ + * ================================================================= + * Ermöglicht das direkte Ausführen von Python-Code im Browser mit 1 Klick! + * Funktioniert mit Pyodide (WebAssembly) oder sicherem lokalem Interpreter. + */ + +(function () { + let pyodideInstance = null; + let isPyodideLoading = false; + + async function getPyodide() { + if (pyodideInstance) return pyodideInstance; + if (isPyodideLoading) { + while (isPyodideLoading) { + await new Promise(r => setTimeout(r, 100)); + } + return pyodideInstance; + } + + isPyodideLoading = true; + try { + if (typeof loadPyodide === "undefined") { + // Dynamisch Pyodide-Script laden + await new Promise((resolve, reject) => { + const script = document.createElement("script"); + script.src = "https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.js"; + script.onload = resolve; + script.onerror = reject; + document.head.appendChild(script); + }); + } + pyodideInstance = await loadPyodide({ + stdout: (text) => appendOutput(text, "stdout"), + stderr: (text) => appendOutput(text, "stderr") + }); + isPyodideLoading = false; + return pyodideInstance; + } catch (e) { + isPyodideLoading = false; + console.warn("Pyodide CDN nicht erreichbar (Offline-Modus aktiv):", e); + return null; + } + } + + let activeOutputEl = null; + + function appendOutput(text, type = "stdout") { + if (!activeOutputEl) return; + const span = document.createElement("div"); + span.style.color = type === "stderr" ? "#f87171" : "#a7f3d0"; + span.textContent = text; + activeOutputEl.appendChild(span); + activeOutputEl.scrollTop = activeOutputEl.scrollHeight; + } + + window.initCodeRunnerWidget = function (containerId, initialCode = "") { + const container = document.getElementById(containerId); + if (!container) return; + + container.innerHTML = ` +
+ Teste deinen Code oder experimentiere mit Beispielen direkt hier im Browser – ohne Terminal! +
+ + + +python3 aufgabe.py!