aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--public/js/calculator.coffee16
-rw-r--r--views/calculator/show.html12
2 files changed, 26 insertions, 2 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()
diff --git a/views/calculator/show.html b/views/calculator/show.html
index 95ee49a1..b20f2737 100644
--- a/views/calculator/show.html
+++ b/views/calculator/show.html
@@ -24,7 +24,17 @@
<input type="text" id="amount" />
<small id="currency"></small>
- <br /><br />
+ <label for="tip">Tip:</label>
+ <div class="btn-toolbar">
+ <div class="btn-group" id="tip">
+ <a id="tip0" class="btn tipSelect active" href="#"><i class="icon-align-left">0%</i></a>
+ <a id="tip10" class="btn tipSelect" href="#"><i class="icon-align-left">10%</i></a>
+ <a id="tip15" class="btn tipSelect" href="#"><i class="icon-align-center">15%</i></a>
+ <a id="tip20" class="btn tipSelect" href="#"><i class="icon-align-right">20%</i></a>
+ </div>
+ </div>
+
+ <br />
<div id="payment">
<p>Please send <strong id="total">0.0</strong> mBTC to</p><br />