diff options
| author | metoro <[email protected]> | 2014-03-14 08:42:36 +0100 |
|---|---|---|
| committer | metoro <[email protected]> | 2014-03-14 08:42:36 +0100 |
| commit | 74d93fd24a7a577bdf26975d2f04897763089241 (patch) | |
| tree | a90e00a77c88b52577c9428731b433f853d9206c /public | |
| parent | 5daf37eaba8eb763458771210e7426db3791d4a3 (diff) | |
| download | coinos-server-74d93fd24a7a577bdf26975d2f04897763089241.tar.gz coinos-server-74d93fd24a7a577bdf26975d2f04897763089241.zip | |
Add tip option on calculator
Diffstat (limited to 'public')
| -rw-r--r-- | public/js/calculator.coffee | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee index 7495576e..72af1987 100644 --- a/public/js/calculator.coffee +++ b/public/js/calculator.coffee @@ -11,6 +11,8 @@ EXCHANGE_FAIL = "Error fetching exchange rate" SOCKET_FAIL = "Error connecting to payment server" ADDRESS_FAIL = "Invalid address" +tip = 1 + g = exports ? this $(-> @@ -39,6 +41,10 @@ $(-> else setup() + $('.tipSelect').click(-> + activateTip(this.id.substring(3)) + updateTotal() + ) $('#amount').keyup(updateTotal) $('#amount').focus(-> $('#received').hide() @@ -48,6 +54,13 @@ $(-> ) ) +activateTip = (p) -> + $('.tipSelect').css('font-weight','normal') + $('.tipSelect').removeClass('active') + $('#tip'+p).css('font-weight','bold') + $('#tip'+p).addClass('active') + tip = 1+(parseFloat(p)/100) + setup = -> g.address or= '1VAnbtCAnYccECnjaMCPnWwt81EHCVgNr' g.commission or= 0 @@ -149,7 +162,7 @@ setupSocket = -> ) updateTotal = -> - amount = parseFloat($('#amount').val()) + amount = parseFloat($('#amount').val() * tip) total = (amount * 1000 / g.exchange).toFixed(5) g.receivable = (amount / g.exchange).toFixed(8) @@ -160,6 +173,7 @@ updateTotal = -> $('#qr').html('') new QRCode('qr', "bitcoin:#{g.address}?amount=#{g.receivable.toString()}") + fail = (msg) -> g.errors.push(msg) g.errors = g.errors.uniq() |
