'use strict'; // NOTE: innerHTML safe - only own API data (numbers, names) var Dashboard = { render: function() { var el = document.getElementById('content'); el.textContent = 'Lade Dashboard...'; API.get('/dashboard').then(function(d) { var cardPct = d.cards_total > 0 ? Math.round((d.cards_learned / d.cards_total) * 100) : 0; var tutPct = d.tutorials_total > 0 ? Math.round((d.tutorials_done / d.tutorials_total) * 100) : 0; var dueText = d.cards_due > 0 ? '' + d.cards_due + ' Karten faellig heute' : 'Keine faelligen Karten — gut gemacht!'; var h = ''; h += '
'; h += '
📚
'; h += '
Flashcards
'; h += '
' + d.cards_total + ' Karten in ' + d.deck_count + ' Decks
'; h += '
'; h += '
' + cardPct + '% gelernt'; if (d.cards_due > 0) h += ' — ' + d.cards_due + ' faellig'; h += '
'; h += '
📖
'; h += '
Tutorials
'; h += '
' + d.tutorials_total + ' Lektionen
'; h += '
'; h += '
' + d.tutorials_done + '/' + d.tutorials_total + ' abgeschlossen
'; h += '
'; h += '
Quiz
Wissen testen
'; if (d.last_quiz_score !== null) { h += '
Letzte Note: ' + d.last_quiz_score + '%
'; } else { h += '
Noch kein Quiz
'; } h += '
'; h += '
📄
'; h += '
Cheat Sheets
'; h += '
' + d.cheatsheet_count + ' Referenzkarten
'; h += '
Schnellreferenz
'; h += '
'; el.innerHTML = h; el.querySelectorAll('.module-tile').forEach(function(tile) { tile.addEventListener('click', function() { location.hash = tile.dataset.href; }); }); }).catch(function(e) { el.textContent = e.message; }); } };