Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
minor currency formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Jan 25, 2016
1 parent fb756ac commit a92b637
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ <h4> Account Information </h4>
<strong class="text-success" id="accountBalanceUsd" style="margin-left: 1em"> loading... </strong>
<br />
<strong class="text-success" id="accountBalanceEur" style="margin-left: 1em"> loading... </strong>
<br />
<strong class="text-success" id="accountBalanceBtc" style="margin-left: 1em"> loading... </strong>
</p>
</div>
<br />
Expand Down
2 changes: 1 addition & 1 deletion js/etherwallet-master.min.js

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions js/source/01_global.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var PrivKey = "";
var decryptType = "";
var usdval;
var eurval;
var btcval;
var web3 = new Web3();
$(document).ready(function() {
bindElements();
Expand Down Expand Up @@ -253,13 +254,17 @@ function setWalletBalance() {
if (!result.error) {
var bestCurAmount = getBestEtherKnownUnit(result.data.balance);
$("#accountBalance").html(bestCurAmount.amount + " " + bestCurAmount.unit);
getETHvalue('USD', function(value) {
getETHvalue('ZUSD', function(value) {
usdval = toFiat(bestCurAmount.amount, bestCurAmount.unit, value);
$("#accountBalanceUsd").html(usdval + " USD");
$("#accountBalanceUsd").html(formatCurrency(usdval,'$') + " USD");
});
getETHvalue('EUR', function(value) {
getETHvalue('ZEUR', function(value) {
eurval = toFiat(bestCurAmount.amount, bestCurAmount.unit, value);
$("#accountBalanceEur").html(eurval + " EUR");
$("#accountBalanceEur").html(formatCurrency(eurval,'€')+ " EUR");
});
getETHvalue('XXBT', function(value) {
btcval = toFiat(bestCurAmount.amount, bestCurAmount.unit, value);
$("#accountBalanceBtc").html(btcval + " BTC");
});
} else
alert(result.msg);
Expand All @@ -278,6 +283,9 @@ function walletDecryptFailed(err) {
$("#wallettransactions").hide();
}

function formatCurrency(n, currency) {
return currency + " " + n.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,");
}
function decryptFormData() {
PrivKey = "";
if (decryptType == 'fupload') {
Expand Down
2 changes: 1 addition & 1 deletion js/source/02_ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function getEthCall(txobj, callback){
$.post( SERVERURL, { ethCall: txobj }).done(callback);
}
function getETHvalue(slavePair, callback){
var prefix = "XETHZ";
var prefix = "XETH";
$.post( KRAKENAPI+"Ticker", { pair: prefix+slavePair }).done(function(data){
callback(data['result'][prefix+slavePair]['o']);
});
Expand Down
2 changes: 2 additions & 0 deletions pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ <h4> Account Information </h4>
<strong class="text-success" id="accountBalanceUsd" style="margin-left: 1em"> loading... </strong>
<br />
<strong class="text-success" id="accountBalanceEur" style="margin-left: 1em"> loading... </strong>
<br />
<strong class="text-success" id="accountBalanceBtc" style="margin-left: 1em"> loading... </strong>
</p>
</div>
<br />
Expand Down

0 comments on commit a92b637

Please sign in to comment.