blob: 090abbe26c951577b3882fa9b79865d21bcfbf99 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#= require js/jquery-1.8.2.min.js
#= require js/bootstrap.min.js
g = exports ? this
$(->
fetchExchangeRate('ask')
fetchExchangeRate('bid')
$('#username').blur(->
$.get(
"/#{$(this).val()}/exists",
username: $(this).val(),
(data) ->
if data is "true"
$('#username').prev().css('color', 'red').html('Username (taken)')
g.preventSubmit = true
else
$('#username').prev().css('color', 'black').html('Username')
g.preventSubmit = false
)
)
$('#signup').submit(->
return false if g.preventSubmit
return true
)
)
fetchExchangeRate = (type) ->
commission = 0.015
commission *= -1 if type is 'bid'
$.ajax(
url: "/ticker?symbol=virtexCAD&type=#{type}&amount=100",
success: (exchange) ->
if not exchange?
exchange = '??'
exchange = exchange - exchange * commission
$("##{type}").html(exchange.toFixed(2))
error: ->
$("##{type}").html('??')
)
|