Finance Blog · Exchange Rate Reference
World Currency Exchange Rates
Live exchange rates against your chosen base currency
Auto-Updated Data
Base currency:
Fetching exchange rates...
All Currencies
No currencies found matching your search.
END ADSTERRA 728x90 LEADERBOARD SCRIPT (Banner #${index+1}) --> `; } function renderFeatured(base,rates){ const box=document.getElementById('featuredBox'); const picks=FEATURED.filter(c=>c!==base).slice(0,3); box.innerHTML=picks.map(c=>{ const r=rates[c];if(!r)return''; const d=deltas[c],cls=d>0?'up':d<0?'dn':'fl',sign=d>0?'+':''; return`
${base}/${c} ${CURRENCIES[c]?.flag||''}
${fmtRate(r)}
${sign}${d}%
`; }).join(''); } function renderGrid(base,rates){ const q=searchQ.toLowerCase(); const entries=Object.entries(rates).filter(([c])=>{ if(c===base)return false; if(!q)return true; const info=CURRENCIES[c]; return c.toLowerCase().includes(q)||(info&&info.name.toLowerCase().includes(q)); }); const container=document.getElementById('gridContainer'); const noRes=document.getElementById('noResult'); const count=entries.length; document.getElementById('countLabel').textContent=`${count} ${count===1?'currency':'currencies'}`; if(!count){container.innerHTML='';noRes.style.display='block';return;} noRes.style.display='none'; let html=''; let adIndex=0; for(let i=0;i
0) html+=``; // close previous grid // Insert leaderboard before each new section (except the very first) if(i>0){ html+=leaderboardHTML(adIndex); adIndex++; } html+=`
`; } const [c,r]=entries[i]; html+=cardHTML(c,r); } html+=`
`; // close last grid container.innerHTML=html; } function renderUpdateTime(){ const now=new Date(); const opts={day:'numeric',month:'long',year:'numeric',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}; document.getElementById('updateTime').textContent='Last updated: '+now.toLocaleString('en-US',opts); } async function fetchRates(base){ try{ const res=await fetch(`https://api.exchangerate-api.com/v4/latest/${base}`); const data=await res.json(); return data.rates||{}; }catch(e){ const b2u={IDR:0.000063,USD:1,EUR:1.08,GBP:1.27,JPY:0.0067,SGD:0.75,MYR:0.22,CNY:0.138,AUD:0.65,SAR:0.267,AED:0.272}; const b=b2u[base]||1; const fake={}; Object.keys(CURRENCIES).forEach(c=>{fake[c]=parseFloat(((b2u[c]||0.5)/b).toFixed(6));}); return fake; } } async function load(base){ document.getElementById('loadMsg').style.display='block'; document.getElementById('mainContent').style.display='none'; allRates=await fetchRates(base); document.getElementById('loadMsg').style.display='none'; document.getElementById('mainContent').style.display='block'; renderFeatured(base,allRates); renderGrid(base,allRates); renderUpdateTime(); } const baseSel=document.getElementById('baseSel'); Object.entries(CURRENCIES).forEach(([c,info])=>{ const o=document.createElement('option'); o.value=c;o.textContent=`${info.flag} ${c} – ${info.name}`; if(c==='USD')o.selected=true; baseSel.appendChild(o); }); baseSel.addEventListener('change',e=>{currentBase=e.target.value;load(currentBase);}); document.getElementById('searchInput').addEventListener('input',e=>{searchQ=e.target.value;renderGrid(currentBase,allRates);}); load('USD');