aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2012-11-29 04:21:30 -0800
committerAdam Soltys <[email protected]>2012-11-29 04:21:37 -0800
commitfe4f809298e63734e450dadb045b5af6405538b4 (patch)
tree0178c964fa1792fdecf9603cca5159eb80a1304b
parentcf810110ec5f8f1387619b9f8c6a35d7f7dcce61 (diff)
downloadcoinos-server-fe4f809298e63734e450dadb045b5af6405538b4.tar.gz
coinos-server-fe4f809298e63734e450dadb045b5af6405538b4.zip
Post exchange rates
-rw-r--r--app.coffee22
-rw-r--r--public/css/index.less2
-rw-r--r--public/js/calculator.coffee2
-rw-r--r--public/js/index.coffee24
-rw-r--r--views/about.html7
-rw-r--r--views/exchangers.html2
-rw-r--r--views/join.html11
-rw-r--r--views/layout.html2
8 files changed, 55 insertions, 17 deletions
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&currency=true'
+ path: "/t/depthcalc.json?symbol=#{req.query.symbol}&type=#{req.query.type}&amount=#{req.query.amount}&currency=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 @@
<p>
Transactions between bitcoin addresses are
recorded in a public file and <a href="http://blockchain.info/unconfirmed-transactions">published on
- the Internet</a>. This file, or "block chain", keeps track of what amounts are
+ the Internet</a>. This file called the block chain keeps track of what amounts are
stored at what addresses.
</p>
@@ -123,15 +123,14 @@
You can <a href="/merchants">spend them locally</a> at one of our participating merchants or check out
<a href="http://bitcoinmagazine.net/where-to-spend-your-bitcoins/">this article</a> for some other good suggestions.
The number of <a href="https://en.bitcoin.it/wiki/Trade">companies accepting bitcoins</a>
- 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.
</p>
</div>
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 @@
<ul>
<li>Contact one of us to let us know your availability and how much you want to spend</li>
<li>We'll arrange a time to meet at a public place like a caf&eacute; or a bank</li>
- <li>At the time of meeting, we'll look up the exchange rate above to determine how many bitcoins to send for the amount you specified</li>
+ <li>At the time of meeting, we'll look up the exchange rate above to determine how many bitcoins to send for the amount specified</li>
<li>You'll provide us with a bitcoin address to send to and count out the cash for us</li>
<li>We'll send the bitcoins to your address using a phone or laptop</li>
<li>When the transaction is confirmed, we take the cash and you keep the bitcoins!</li>
diff --git a/views/join.html b/views/join.html
new file mode 100644
index 00000000..26f88887
--- /dev/null
+++ b/views/join.html
@@ -0,0 +1,11 @@
+<h1>Join Us</h1>
+
+<p>
+If you're a resident of Vancouver and would like to be listed as a local exchanger here, come to our monthly meetup group and introduce yourself! We'll teach you everything you need to know and if you agree to use our posted rates and we get the sense that you'll be fair and professional then we'll happily list you on our <a href="/exchangers">exchangers page</a>.
+</p>
+
+<h2>Our Rates</h2>
+
+<p>
+The exchange rates on this website are pegged to the current market prices at <a href="http://cavirtex.com/">cavirtex.com</a> and are updated every 15 minutes. Specifically, we take an average of the bid/ask prices in the order books there using a market depth of $1000 CAD.
+</p>
diff --git a/views/layout.html b/views/layout.html
index dbac084f..184a970c 100644
--- a/views/layout.html
+++ b/views/layout.html
@@ -15,7 +15,7 @@
<a class="brand" href="/">VanBTC</a>
<div class="nav-collapse collapse">
<p class="navbar-text pull-right">
- Exchange Rate: <b class="exchange"></b> |
+ Buy: <b id="ask"></b> | Sell: <b id="bid"></b> |
<a href="/login" class="navbar-link">Login</a>
</p>
<ul class="nav">