';
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 || '')) + '
';
if (fc.evidence) {
var ev = this.fixUmlauts(fc.evidence);
ev = this.esc(ev).replace(/(https?:\/\/[^\s,)]+)/g, '$1');
h += '
Evidenz: ' + ev + '
';
}
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');
}
});
},
/* ===== SMOOTH SCROLL FOR CITATIONS ===== */
initSmoothScroll: function() {
document.addEventListener('click', function(e) {
var link = e.target.closest('.citation-ref');
if (!link) return;
e.preventDefault();
var href = link.getAttribute('href');
if (!href) return;
var targetId = href.substring(1);
var target = document.getElementById(targetId);
if (!target) return;
target.scrollIntoView({ behavior: 'smooth', block: 'center' });
target.classList.add('source-highlight');
setTimeout(function() {
target.classList.remove('source-highlight');
}, 1500);
});
},
/* ===== SCROLL REVEAL ===== */
initScrollReveal: function() {
var cards = document.querySelectorAll('.content-card, .lagebild-cta');
if (!('IntersectionObserver' in window)) {
// Fallback: show all immediately
for (var i = 0; i < cards.length; i++) cards[i].classList.add('revealed');
return;
}
var observer = new IntersectionObserver(function(entries) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
entry.target.classList.add('revealed');
observer.unobserve(entry.target);
}
});
}, { threshold: 0.1 });
for (var i = 0; i < cards.length; i++) {
cards[i].classList.add('reveal');
observer.observe(cards[i]);
}
},
/* ===== HILFSFUNKTIONEN ===== */
extractDomain: function(url) {
if (!url) return null;
try { return new URL(url).hostname; } catch(e) { return null; }
},
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; },
toUTC: function(s) {
if (!s) return s;
s = String(s).trim();
if (/[Zz]$/.test(s) || /[+-]\d{2}:?\d{2}$/.test(s)) return s;
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 opts = { timeZone: TIMEZONE, weekday: 'long', day: 'numeric', month: 'long', year: 'numeric', hour: '2-digit', minute: '2-digit', hour12: false };
var parts = new Intl.DateTimeFormat('de-DE', opts).formatToParts(d);
var p = {};
parts.forEach(function(x) { p[x.type] = x.value; });
return p.weekday + ', ' + p.day + '. ' + p.month + ' ' + p.year
+ ' um ' + p.hour + ':' + p.minute + ' Uhr';
} catch(e) { return iso; }
},
fmtDateOnly: function(iso) {
if (!iso) return '';
try {
var d = new Date(this.toUTC(iso));
if (isNaN(d.getTime())) return iso;
return d.toLocaleDateString('de-DE', { day: 'numeric', month: 'short', year: 'numeric', timeZone: TIMEZONE });
} 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', timeZone: TIMEZONE }); }
catch(e) { return iso; }
},
showError: function() {
document.getElementById('summary-content').innerHTML =
'
Das Lagebild konnte nicht geladen werden. Bitte versuchen Sie es später erneut.