aboutsummaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2015-11-19 17:05:14 -0800
committerAdam Soltys <[email protected]>2015-11-27 22:02:48 -0800
commit112d1459efc2b1c665706eda2f46ddb06717e565 (patch)
treec16458237203fe9b2afffd7af6172ce812552c14 /public
parentd9373fb974724b2fa5accf42e766cca712d169d2 (diff)
downloadcoinos-server-112d1459efc2b1c665706eda2f46ddb06717e565.tar.gz
coinos-server-112d1459efc2b1c665706eda2f46ddb06717e565.zip
Set amount field range and formatting
Diffstat (limited to 'public')
-rw-r--r--public/js/wallet.coffee15
1 files changed, 14 insertions, 1 deletions
diff --git a/public/js/wallet.coffee b/public/js/wallet.coffee
index ec97bace..dda576e7 100644
--- a/public/js/wallet.coffee
+++ b/public/js/wallet.coffee
@@ -36,6 +36,7 @@ $(->
g.amount = parseFloat($('#amount').val()).toFixed(precision())
$('#amount').val((g.amount * g.exchange / multiplier()).toFixed(2))
$(this).html(g.user.currency)
+ $('#amount').attr('step', 0.01)
else
amount = parseFloat($('#amount').val() * multiplier() / g.exchange).toFixed(precision())
if Math.abs(g.amount - amount).toFixed(precision()) > (.000000005 * g.exchange * multiplier()).toFixed(precision())
@@ -44,14 +45,25 @@ $(->
$('#amount').val(g.amount)
$(this).html(g.user.unit)
+ $('#amount').attr('step', 0.00000001 * multiplier())
)
$('#max').click(->
if $('#currency_toggle').html() is g.user.unit
$('#amount').val(g.balance)
+ $('#amount').attr('max', g.balance)
else
g.amount = parseFloat(g.balance).toFixed(precision())
- $('#amount').val((g.balance / multiplier() * g.exchange).toFixed(2))
+ amount = (g.balance / multiplier() * g.exchange).toFixed(2)
+ $('#amount').val(amount)
+ $('#amount').attr('max', amount)
+ )
+
+ $('#amount').change(->
+ if $('#currency_toggle').html() is g.user.unit
+ $(this).val(parseFloat($(this).val()).toFixed(precision()))
+ else
+ $(this).val(parseFloat($(this).val()).toFixed(2))
)
)
@@ -70,6 +82,7 @@ getUser = ->
$('#unit').html(user.unit)
$('#currency_toggle').html(user.unit)
$('form').fadeIn()
+ $('#amount').attr('step', 0.00000001 * multiplier())
getExchangeRate()
)