(function () { const api = '/wp-json/ralli/v1/sonuclar';
const table = document.getElementById('ralli-results'); const selector = document.getElementById('ralli-table'); const status = document.getElementById('ralli-status'); const updated = document.getElementById('ralli-updated'); const refresh = document.getElementById('ralli-refresh');
let tables = [];
function render(index) { table.replaceChildren();
const rows = tables[index] || [];
rows.forEach((cells, rowIndex) => { const tr = document.createElement('tr');
cells.forEach(value => { const cell = document.createElement( rowIndex === 0 ? 'th' : 'td' ); cell.textContent = value; tr.appendChild(cell); });
table.appendChild(tr); }); }
async function loadResults() { status.textContent = 'Sonuçlar güncelleniyor...';
try { const response = await fetch( api + '?t=' + Date.now(), { cache: 'no-store' } );
if (!response.ok) { throw new Error('HTTP ' + response.status); }
const data = await response.json();
if (!data.success || !data.tables?.length) { throw new Error('Kaynakta okunabilir tablo bulunamadı.'); }
tables = data.tables;
const selected = Number(selector.value) || 0; const active = Math.min(selected, tables.length - 1);
selector.replaceChildren();
tables.forEach((rows, index) => { const option = document.createElement('option'); option.value = index; option.textContent = 'Sonuç Tablosu ' + (index + 1); selector.appendChild(option); });
selector.value = active; render(active);
updated.textContent = 'Güncelleme: ' + new Date().toLocaleTimeString('tr-TR');
status.textContent = '';
} catch (error) { status.textContent = 'Hata: ' + error.message; } }
selector.addEventListener('change', () => { render(Number(selector.value)); });
refresh.addEventListener('click', loadResults);
loadResults(); setInterval(loadResults, 30000); })();
RALLİ CANLI SONUÇLAR
TOSFED Resmî Zamanlama
● CANLI
Veriler bekleniyor…




