Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #118 from gratipay/trailing-zero
Browse files Browse the repository at this point in the history
Solve significant digits
  • Loading branch information
mattbk committed Apr 2, 2016
2 parents 3c0ddb3 + c5bd7a8 commit c005194
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/v1/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@
Gratipay.users.getPublic(username, function(data) {
element.setAttribute('data-gratipay-readystatus', 'ready');
// If ~user versus team
text('receiving', (data.taking)? '$' + data.taking : '$' + data.receiving);
console.log(data.receiving);
// Solve lack of two significant digits in some cases (http://stackoverflow.com/a/4937261/2152245)
text('receiving', (data.taking)? '$' + parseFloat(data.taking).toFixed(2) : '$' + parseFloat(data.receiving).toFixed(2));
text('username', data.username);
text('my-tip-button', data.my_tip == 'self' ? 'You!' : (+data.my_tip > 0 ? data.my_tip : 'Gratipay')); // jshint ignore:line
text('goal', '$' + data.goal);
Expand Down
4 changes: 2 additions & 2 deletions test/gratipay.com/rummik/public.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
"user_name": "rummik"
}
},
"giving": "0.00",
"giving": "0.20",
"id": 16757,
"ngiving_to": 0,
"ntaking_from": 0,
"on": "gratipay",
"taking": "12.34",
"taking": "12.30",
"username": "rummik"
}

0 comments on commit c005194

Please sign in to comment.