Skip to content

Commit

Permalink
Add CDI index
Browse files Browse the repository at this point in the history
  • Loading branch information
gutomotta authored and Guto committed Feb 11, 2021
1 parent aa33c63 commit cd5437b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
<body>
<div class="full-frame">
<div id="main-panel" class="main-panel faded">
<span>CDI agora:</span>
<h1 class="blue" id="yearly-cdi"></h1>
<span>Taxa DI:</span>
<h1 class="blue" id="yearly-cdi">-</h1>
<span>Por mês:</span>
<h2 class="blue" id="monthly-cdi"></h2>
<h2 class="blue" id="monthly-cdi">-</h2>
<span>Índice DI:</span>
<h2 class="blue" id="index-cdi">-</h2>
<p>em <span id="updated-at"></span></p>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions js/cdi-agora.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ function formatPct(num) {
return (Math.round(num * 1e3) / 1e3).toLocaleString('pt-BR') + " %";
}

function fillPage(yearlyCDI, monthlyCDI, updatedAt) {
function fillPage(yearlyCDI, monthlyCDI, indexCDI, updatedAt) {
document.getElementById("yearly-cdi").innerHTML = formatPct(yearlyCDI);
document.getElementById("monthly-cdi").innerHTML = formatPct(monthlyCDI);
document.getElementById("index-cdi").innerHTML = indexCDI;
document.getElementById("updated-at").innerHTML = updatedAt;
}

Expand All @@ -25,8 +26,9 @@ b3_request.onreadystatechange = function() {
var yearlyCDI = parseFloat(json.taxa.replace(',', '.'));
var monthlyCDI = yearToMonth(yearlyCDI);
var updatedAt = json.dataTaxa;
var indexCDI = json.indice;

fillPage(yearlyCDI, monthlyCDI, updatedAt);
fillPage(yearlyCDI, monthlyCDI, indexCDI, updatedAt);
showMainPanel();
}
};
Expand Down

0 comments on commit cd5437b

Please sign in to comment.