From fe4f809298e63734e450dadb045b5af6405538b4 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 29 Nov 2012 04:21:30 -0800 Subject: Post exchange rates --- app.coffee | 22 +++++++++++++--------- public/css/index.less | 2 +- public/js/calculator.coffee | 2 +- public/js/index.coffee | 24 ++++++++++++++++++++++++ views/about.html | 7 +++---- views/exchangers.html | 2 +- views/join.html | 11 +++++++++++ views/layout.html | 2 +- 8 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 views/join.html diff --git a/app.coffee b/app.coffee index 75cdf310..46d3260f 100644 --- a/app.coffee +++ b/app.coffee @@ -37,13 +37,19 @@ app.use(passport.initialize()) app.use(passport.session()) app.use(app.router) -for route in ['', 'about', 'exchangers', 'merchants'] - ((route) -> - app.get("/#{route}", (req, res) -> - route = 'index' if route == '' - res.render(route, js: (-> global.js), css: (-> global.css), layout: 'layout') +routes = + "/": 'index' + "/about": 'about' + "/exchangers": 'exchangers' + "/exchangers/new": 'join' + "/merchants": 'merchants' + +for route, view of routes + ((route, view) -> + app.get(route, (req, res) -> + res.render(view, js: (-> global.js), css: (-> global.css), layout: 'layout') ) - )(route) + )(route, view) app.get('/setup', (req, res) -> res.render('setup', js: (-> global.js), css: (-> global.css)) @@ -86,9 +92,7 @@ app.get('/:user/transactions', (req, res) -> app.get('/ticker', (req, res) -> options = host: 'bitcoincharts.com', - path: '/t/depthcalc.json?symbol=' + - req.query.symbol + - '&type=ask&amount=1000¤cy=true' + path: "/t/depthcalc.json?symbol=#{req.query.symbol}&type=#{req.query.type}&amount=#{req.query.amount}¤cy=true" require('http').get(options, (r) -> r.setEncoding('utf-8') diff --git a/public/css/index.less b/public/css/index.less index 35eb9420..cc31fc1b 100644 --- a/public/css/index.less +++ b/public/css/index.less @@ -9,6 +9,6 @@ footer { text-align: right; } -b.exchange { color: white; } +#ask, #bid { color: white; } div.directory img { width: 150px; height: 150px; float: left; padding-right: 20px; } div.row-fluid td.first { text-align: right; } diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee index 9a66167a..78e5d91c 100644 --- a/public/js/calculator.coffee +++ b/public/js/calculator.coffee @@ -82,7 +82,7 @@ setup = -> fetchExchangeRate = -> $.ajax( - url: 'ticker?symbol=' + g.symbol, + url: "ticker?symbol=#{g.symbol}&type=ask&amount=1000", cache: false, success: (exchange) -> if exchange? 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) diff --git a/views/about.html b/views/about.html index 44d4a982..c7f5f45a 100644 --- a/views/about.html +++ b/views/about.html @@ -13,7 +13,7 @@

Transactions between bitcoin addresses are recorded in a public file and published on - the Internet. This file, or "block chain", keeps track of what amounts are + the Internet. This file called the block chain keeps track of what amounts are stored at what addresses.

@@ -123,15 +123,14 @@ You can spend them locally at one of our participating merchants or check out this article for some other good suggestions. The number of companies accepting bitcoins - is growing quickly. We're working to get more stores accepting them in + is growing quickly and we're working to get more stores accepting them in Vancouver. We believe it'll be in their best interest to avoid the transaction fees charged by the credit card companies. Transaction fees end up getting built into the prices we pay for goods and services across the board so we're indirectly subsidizing the big banks and credit card - companies whether we personally use their services - or not. + companies whether or not we personally use their services.

diff --git a/views/exchangers.html b/views/exchangers.html index 8623e4e1..e249ee48 100644 --- a/views/exchangers.html +++ b/views/exchangers.html @@ -13,7 +13,7 @@