aboutsummaryrefslogtreecommitdiffstats
path: root/public/js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2013-12-09 13:40:32 -0800
committerAdam Soltys <[email protected]>2013-12-09 13:40:39 -0800
commitbb9c452eb37be653a4f732d9852ca2dcdafba1bd (patch)
treedef5c5033688da6b0324e3699db87f4919a4df4d /public/js
parentd740936228b7ef5c14330def5ce6f574eadaf609 (diff)
downloadcoinos-server-bb9c452eb37be653a4f732d9852ca2dcdafba1bd.tar.gz
coinos-server-bb9c452eb37be653a4f732d9852ca2dcdafba1bd.zip
Fix rounding issues and switch to mBTC
Diffstat (limited to 'public/js')
-rw-r--r--public/js/calculator.coffee10
-rw-r--r--public/js/report.coffee1
2 files changed, 6 insertions, 5 deletions
diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee
index 2de19ee9..1602fb3a 100644
--- a/public/js/calculator.coffee
+++ b/public/js/calculator.coffee
@@ -21,6 +21,7 @@ $(->
g.commission = parseFloat(get('commission'))
g.logo = get('logo')
g.errors = []
+ g.receivable = 0
if g.user
$.ajax(
@@ -121,7 +122,6 @@ setupSocket = ->
g.websocket.onmessage = (e) ->
results = eval('(' + e.data + ')')
from_address = ''
- total = 0
received = 0
$.each(results.x.out, (i, v) ->
@@ -135,7 +135,7 @@ setupSocket = ->
input -= v.prev_out.value / 100000000
)
- if (total <= received)
+ if (g.receivable <= received)
$('#amount').blur()
$('#payment').hide()
$('#received').fadeIn('slow')
@@ -150,15 +150,15 @@ setupSocket = ->
updateTotal = ->
amount = parseFloat($('#amount').val())
- total = amount / g.exchange
- total = Math.ceil(total * 10000) / 10
+ total = (amount * 1000 / g.exchange).toFixed(5)
+ g.receivable = (amount / g.exchange).toFixed(8)
unless $.isNumeric(total)
total = ''
$('#total').html(total.toString())
$('#qr').html('')
- new QRCode('qr', "bitcoin:#{g.address}?amount=#{total.toString()}")
+ new QRCode('qr', "bitcoin:#{g.address}?amount=#{g.receivable.toString()}")
fail = (msg) ->
g.errors.push(msg)
diff --git a/public/js/report.coffee b/public/js/report.coffee
index 6654c692..372abe7b 100644
--- a/public/js/report.coffee
+++ b/public/js/report.coffee
@@ -48,6 +48,7 @@ display = (transactions) ->
exchange = parseFloat(this.exchange)
received = parseFloat(this.received)
amount = received * exchange
+ received *= 1000
$('tbody').append("""
<tr>