From 16062edf148ea44bc8a5f40732c0dc1d363d588c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 13 Nov 2012 19:27:09 -0800 Subject: Allow market selection --- public/js/calculator.coffee | 21 ++++++++++++--------- public/js/index.coffee | 9 +++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 public/js/index.coffee (limited to 'public') diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee index 01523d9a..3d1d61b4 100644 --- a/public/js/calculator.coffee +++ b/public/js/calculator.coffee @@ -8,8 +8,9 @@ g = exports ? this $(-> g.websocket = null g.user = $('#user').val() - g.title = get('title') + g.name = get('name') g.address = get('address') + g.symbol = get('symbol') g.commission = get('commission') g.logo = get('logo') g.exchange = 0 @@ -20,7 +21,7 @@ $(-> if user? and user $.getJSON(user + '.json', (data) -> - g.title = data.name + g.name = data.name g.address = data.address g.commission = data.commission g.logo = data.logo @@ -53,7 +54,7 @@ exchangeFail = -> $('#calculator').hide() fetchExchangeRate = -> - $.getJSON('ticker') + $.getJSON('ticker?symbol=' + g.symbol) .success((data) -> unless data? exchangeFail() @@ -71,18 +72,20 @@ fetchExchangeRate = -> setTimeout(fetchExchangeRate, 900000) setupPage = -> - unless g.address - g.address = '1VAnbtCAnYccECnjaMCPnWwt81EHCVgNr' - - unless g.commission - g.commission = 3 + g.address or= '1VAnbtCAnYccECnjaMCPnWwt81EHCVgNr' + g.commission or= 3 + g.symbol or= 'virtexCAD' if g.logo $('#logo').attr('src', g.logo).show() + else if not g.name + $('#logo').attr('src', 'img/bitcoin.png').show() else - $('#title').html(title).show() + $('#name').html(g.name).show() $('#address').html(g.address) + $('#symbol').html(g.symbol + " - " + commission.toFixed(0) + "%") + $('#currency').html(g.symbol.slice(-3)) $('#received').hide() fetchExchangeRate() diff --git a/public/js/index.coffee b/public/js/index.coffee new file mode 100644 index 00000000..d832c4ed --- /dev/null +++ b/public/js/index.coffee @@ -0,0 +1,9 @@ +#= require jquery-1.8.2.min.js + +$(-> + symbols = ['mtgoxUSD', 'btceUSD', 'bitstampUSD', 'virwoxSLL', 'btcdeEUR', 'mtgoxEUR', 'btc24EUR', 'mtgoxAUD', 'cryptoxAUD', 'mtgoxGBP', 'btcnCNY', 'intrsngEUR', 'virtexCAD', 'mtgoxPLN', 'cbxUSD', 'bitcurexPLN', 'bitmarketEUR', 'bitfloorUSD', 'mrcdBRL', 'bcEUR'] + + $.each(symbols, (i, v) -> + $('#symbol').append("") + ) +) -- cgit v1.2.3