This repository has been archived by the owner on Sep 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 495
[FIX] Advanced trade: fix values calculations #2417
Merged
mrajvanshy
merged 1 commit into
ripple:develop
from
darkdarkdragon:develop-fix-trade-input
Apr 29, 2015
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,14 +396,15 @@ TradeTab.prototype.angular = function(module) | |
$scope.fill_widget = function (type, order, sum) { | ||
$scope.reset_widget(type); | ||
|
||
$scope.order[type].price = order.price.to_human().replace(',',''); | ||
$scope.order[type].price = order.price.to_human({group_sep: false}); | ||
|
||
if (sum) { | ||
$scope.order[type].first = order.sum.to_human().replace(',',''); | ||
$scope.order[type].first = order.sum.to_human({group_sep: false}); | ||
$scope.calc_second(type); | ||
} | ||
scrollToElement('widgetGroup'); | ||
}; | ||
|
||
function scrollToElement(element) { | ||
var el = document.getElementById(element); | ||
var yPos = el.getClientRects()[0].top; | ||
|
@@ -416,6 +417,7 @@ TradeTab.prototype.angular = function(module) | |
} | ||
},5); | ||
} | ||
|
||
/** | ||
* Happens when user clicks on 'Place Order' button. | ||
* | ||
|
@@ -814,7 +816,7 @@ TradeTab.prototype.angular = function(module) | |
|
||
if (type === 'buy') bestPrice = $scope.bookShow.bids[0].showPrice; | ||
else if (type === 'sell') bestPrice = $scope.bookShow.asks[0].showPrice; | ||
bestPrice = +bestPrice.replace(',',''); | ||
bestPrice = +bestPrice.replace(/,/g, ''); | ||
|
||
return (bestPrice && | ||
(price > (bestPrice * fatFingerMarginMultiplier) || | ||
|
@@ -834,7 +836,7 @@ TradeTab.prototype.angular = function(module) | |
if (order.price_amount && order.price_amount.is_valid() && | ||
order.first_amount && order.first_amount.is_valid()) { | ||
order.second_amount = order.price_amount.product_human(order.first_amount); | ||
order.second = +order.second_amount.to_human({group_sep: false}); | ||
order.second = order.second_amount.to_human({group_sep: false}); | ||
} | ||
}; | ||
|
||
|
@@ -852,15 +854,16 @@ TradeTab.prototype.angular = function(module) | |
order.second_amount && order.second_amount.is_valid()) { | ||
|
||
if (!order.price_amount.is_native()) { | ||
var price = order.price_amount.to_human(); | ||
var price = order.price_amount.to_human({group_sep: false}); | ||
var currency = order.price_amount.currency().to_json(); | ||
var issuer = order.price_amount.issuer().to_json(); | ||
|
||
order.first_amount = Amount.from_json(order.second_amount.to_text_full()).ratio_human(Amount.from_json(price + '/' + currency + '/' + issuer), {reference_date: new Date()}); | ||
// use replace(/,/g,'') until ripple lib fixed | ||
order.first_amount = Amount.from_json(order.second_amount.to_text_full().replace(/,/g, '')).ratio_human(Amount.from_json(price + '/' + currency + '/' + issuer), {reference_date: new Date()}); | ||
} else { | ||
order.first_amount = Amount.from_json(order.second_amount.to_text_full()).ratio_human(Amount.from_json(order.price_amount.to_text()), {reference_date: new Date()}); | ||
order.first_amount = Amount.from_json(order.second_amount.to_text_full().replace(/,/g, '')).ratio_human(Amount.from_json(order.price_amount.to_text()), {reference_date: new Date()}); | ||
} | ||
order.first = +order.first_amount.to_human({group_sep: false}); | ||
order.first = order.first_amount.to_human({group_sep: false}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
} | ||
}; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the
+
killed? It's a conversion to number.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jublo That was whole point of this commit. This value goes into input field. And when it is number, chrome shows it in e-notation if it too small or too big
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. Well done then.