';
return;
}
// Statistik
var stats = {confirmed:0, unconfirmed:0, contradicted:0, developing:0, established:0, disputed:0};
for (var k = 0; k < checks.length; k++) {
var st = checks[k].status || 'developing';
if (stats[st] !== undefined) stats[st]++;
}
var h = '
';
// Sortierung: mit History zuerst, dann sources_count
checks = checks.slice().sort(function(a, b) {
var aH = (a.status_history || []).length;
var bH = (b.status_history || []).length;
if (bH !== aH) return bH - aH;
return (b.sources_count || 0) - (a.sources_count || 0);
});
for (var i = 0; i < checks.length; i++) {
var fc = checks[i];
var status = fc.status || 'developing';
var hasProg = fc.status_history && fc.status_history.length > 1;
h += '
';
h += '
';
h += '' + this.stLabel(status) + '';
h += '' + (fc.sources_count || 0) + ' unabhängige Quellen';
h += '
';
h += '
' + this.esc(this.fixUmlauts(fc.claim || '')) + '
';
// Vollständige Evidenz anzeigen
if (fc.evidence) {
var ev = this.fixUmlauts(fc.evidence);
// URLs in der Evidenz klickbar machen
ev = this.esc(ev).replace(/(https?:\/\/[^\s,)]+)/g, '$1');
h += '
Evidenz: ' + ev + '
';
}
// Status-Verlauf
if (hasProg) {
h += '
';
h += 'Verlauf:';
for (var j = 0; j < fc.status_history.length; j++) {
var step = fc.status_history[j];
if (j > 0) h += '→';
h += '';
h += '' + this.stLabel(step.status) + '';
if (step.at) h += '' + this.fmtShort(step.at) + '';
h += '';
}
h += '
';
}
h += '
';
}
document.getElementById('factchecks-content').innerHTML = h;
},
// ===== TABS =====
initTabs: function() {
var btns = document.querySelectorAll('.tab-btn');
var self = this;
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener('click', function() {
var tab = this.getAttribute('data-tab');
for (var j = 0; j < btns.length; j++) btns[j].classList.remove('active');
this.classList.add('active');
var panels = document.querySelectorAll('.tab-panel');
for (var j = 0; j < panels.length; j++) panels[j].classList.remove('active');
document.getElementById('panel-' + tab).classList.add('active');
if (tab === 'karte') self.renderMap();
});
}
},
initLangToggle: function() {
var btn = document.querySelector('.lang-toggle');
if (!btn) return;
btn.addEventListener('click', function(e) {
e.preventDefault();
if (typeof switchLanguage === 'function') {
var cur = (typeof getCurrentLanguage === 'function') ? getCurrentLanguage() : 'de';
switchLanguage(cur === 'de' ? 'en' : 'de');
}
});
},
// ===== HILFSFUNKTIONEN =====
fixUmlauts: function(text) {
if (!text) return text;
var skip = ['Israel','Israelis','Jazeera','Euronews','Reuters','Februar',
'Juffair','abgefeuert','Feindseligkeiten','Gegenschlag','neuesten',
'auszuweiten','befeuert','feuerte','Feuer','feuer','neue','neuen',
'neuer','neues','Neue','Aero','aero','Manoeuvre','Dauerfeuer'];
var ph = []; var c = 0;
for (var i = 0; i < skip.length; i++) {
var re = new RegExp('\\b' + skip[i] + '\\b', 'g');
text = text.replace(re, function(m) { ph.push(m); return '##S' + (c++) + '##'; });
}
text = text.replace(/ae/g, '\u00e4').replace(/Ae/g, '\u00c4');
text = text.replace(/oe/g, '\u00f6').replace(/Oe/g, '\u00d6');
text = text.replace(/ue/g, '\u00fc').replace(/Ue/g, '\u00dc');
text = text.replace(/##S(\d+)##/g, function(m, idx) { return ph[parseInt(idx)]; });
return text;
},
stLabel: function(s) {
return {confirmed:'Bestätigt',unconfirmed:'Unbestätigt',established:'Gesichert',
unverified:'Nicht verifiziert',contradicted:'Widerlegt',disputed:'Umstritten',
developing:'In Entwicklung','false':'Falsch'}[s] || s;
},
mdToHtml: function(md) {
if (!md) return '';
var lines = md.split('\n'), html = '', inList = false;
for (var i = 0; i < lines.length; i++) {
var l = lines[i];
if (/^### (.+)$/.test(l)) { if(inList){html+='';inList=false;} html+='
'+l.replace(/^### /,'')+'
'; continue; }
if (/^## (.+)$/.test(l)) { if(inList){html+='';inList=false;} html+='
'+l.replace(/^## /,'')+'
'; continue; }
if (/^[-*] (.+)$/.test(l)) { if(!inList){html+='
';inList=true;} html+='
'+l.replace(/^[-*] /,'')+'
'; continue; }
if (inList) { html+='
'; inList=false; }
if (l.trim()==='') continue;
html += '
' + l + '
';
}
if (inList) html += '';
html = html.replace(/\*\*(.+?)\*\*/g, '$1');
html = html.replace(/\*(.+?)\*/g, '$1');
return html;
},
esc: function(s) { if(!s)return''; var d=document.createElement('div'); d.textContent=s; return d.innerHTML; },
truncUrl: function(u) { try{return new URL(u).hostname;}catch(e){return u;} },
// Timestamps aus der DB sind UTC, aber ohne Zeitzone-Suffix.
// Diese Funktion haengt 'Z' an falls noetig, damit der Browser korrekt nach CET konvertiert.
toUTC: function(s) {
if (!s) return s;
s = String(s).trim();
// Hat schon Zeitzone (+00:00, Z, +01:00 etc.)? Dann nichts tun.
if (/[Zz]$/.test(s) || /[+-]\d{2}:?\d{2}$/.test(s)) return s;
// "2026-03-07 00:42:01" -> "2026-03-07T00:42:01Z"
return s.replace(' ', 'T') + 'Z';
},
fmtDT: function(iso) {
if (!iso) return '';
try {
var d = new Date(this.toUTC(iso));
if (isNaN(d.getTime())) return iso;
var tage = ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'];
var mon = ['Januar','Februar','M\u00e4rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'];
return tage[d.getDay()] + ', ' + d.getDate() + '. ' + mon[d.getMonth()] + ' ' + d.getFullYear()
+ ' um ' + ('0'+d.getHours()).slice(-2) + ':' + ('0'+d.getMinutes()).slice(-2) + ' Uhr';
} catch(e) { return iso; }
},
fmtShort: function(iso) {
if (!iso) return '';
try { return new Date(this.toUTC(iso)).toLocaleDateString('de-DE', {day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}); }
catch(e) { return iso; }
},
showError: function() {
document.getElementById('summary-content').innerHTML =
'
Das Lagebild konnte nicht geladen werden. Bitte versuchen Sie es sp\u00e4ter erneut.