// Tema
function temaDegistir() {
const kok = document.documentElement;
kok.dataset.tema = kok.dataset.tema === 'koyu' ? 'acik' : 'koyu';
kok.setAttribute('data-bs-theme', kok.dataset.tema === 'koyu' ? 'dark' : 'light');
try { localStorage.setItem('tema', kok.dataset.tema); } catch (e) {}
window.dispatchEvent(new Event('tema'));
}
const hareketYok = matchMedia('(prefers-reduced-motion: reduce)').matches;
// Sayaçlar: <span data-say="1250.5" data-ondalik="2">
document.querySelectorAll('[data-say]').forEach((el) => {
const hedef = parseFloat(el.dataset.say) || 0;
const ondalik = parseInt(el.dataset.ondalik || '0', 10);
const yaz = (n) => { el.textContent = n.toLocaleString('tr-TR', { minimumFractionDigits: ondalik, maximumFractionDigits: ondalik }); };
if (hareketYok || hedef === 0) return yaz(hedef);
const basla = performance.now(), sure = 900;
(function adim(simdi) {
const t = Math.min(1, (simdi - basla) / sure);
yaz(hedef * (1 - Math.pow(1 - t, 3)));
if (t < 1) requestAnimationFrame(adim);
})(basla);
});
// Silme gibi geri alınamaz işlemler için onay: <form data-onay="...">
document.addEventListener('submit', (e) => {
const soru = e.target.dataset && e.target.dataset.onay;
if (soru && !confirm(soru)) e.preventDefault();
});
// Bildirimler kendiliğinden kapanır
document.querySelectorAll('.bildirim').forEach((b) => setTimeout(() => b.remove(), b.classList.contains('hata') ? 9000 : 5000));
// Grafikler: tema değişince yeniden boyanır
const grafikler = [];
function cssDeger(ad) { return getComputedStyle(document.body || document.documentElement).getPropertyValue(ad).trim(); }
function grafikTema() {
const koyu = document.documentElement.dataset.tema === 'koyu';
return {
theme: { mode: koyu ? 'dark' : 'light' },
chart: { background: 'transparent', foreColor: cssDeger('--tblr-secondary'), fontFamily: 'inherit' },
grid: { borderColor: cssDeger('--tblr-border-color'), strokeDashArray: 4 },
tooltip: { theme: koyu ? 'dark' : 'light' },
stroke: { colors: [cssDeger('--tblr-bg-surface')] },
};
}
function grafikCiz(el, secenek) {
if (!window.ApexCharts || !el) return;
const t = grafikTema();
secenek.chart = Object.assign({ toolbar: { show: false }, animations: { enabled: !hareketYok, speed: 700 } }, secenek.chart, t.chart);
secenek.grid = Object.assign({}, t.grid, secenek.grid);
secenek.theme = t.theme;
secenek.tooltip = Object.assign({}, secenek.tooltip, t.tooltip);
if (secenek.chart.type === 'donut' || secenek.chart.stacked) secenek.stroke = Object.assign({ width: 2 }, secenek.stroke, t.stroke);
const g = new ApexCharts(el, secenek);
g.render();
grafikler.push(g);
}
window.addEventListener('tema', () => {
const t = grafikTema();
grafikler.forEach((g) => g.updateOptions({ theme: t.theme, chart: t.chart, grid: t.grid, tooltip: t.tooltip, stroke: { colors: t.stroke.colors } }, false, false));
});
const tlYaz = (n) => Number(n).toLocaleString('tr-TR', { maximumFractionDigits: 0 }) + ' ₺';
// Listelerde anında arama: <input data-ara="#hedef"> → hedef içindeki [data-ara] öğeleri süzülür
document.querySelectorAll('input[data-ara-hedef]').forEach((giris) => {
const ogeler = document.querySelectorAll(giris.dataset.araHedef + ' [data-ara]');
giris.addEventListener('input', () => {
const q = giris.value.toLocaleLowerCase('tr-TR').trim();
ogeler.forEach((o) => { o.hidden = q !== '' && !o.dataset.ara.includes(q); });
});
});
Lisans bilgisi projenin LICENSE dosyasında.