aboutsummaryrefslogtreecommitdiffstats
path: root/public/js/index.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/index.coffee')
-rw-r--r--public/js/index.coffee24
1 files changed, 24 insertions, 0 deletions
diff --git a/public/js/index.coffee b/public/js/index.coffee
index e69de29b..7db59a66 100644
--- a/public/js/index.coffee
+++ b/public/js/index.coffee
@@ -0,0 +1,24 @@
+#= require jquery-1.8.2.min.js
+
+$(->
+ fetchExchangeRate('ask')
+ fetchExchangeRate('bid')
+)
+
+fetchExchangeRate = (type) ->
+ commission = 0.03
+ commission *= -1 if type is 'bid'
+
+ $.ajax(
+ url: "ticker?symbol=virtexCAD&type=#{type}&amount=1000",
+ cache: false,
+ success: (exchange) ->
+ if not exchange?
+ exchange = '??'
+
+ exchange = exchange - exchange * commission
+ $("##{type}").html(exchange.toFixed(2))
+ error: ->
+ $("##{type}").html('??')
+ )
+ setTimeout(fetchExchangeRate, 900000)