aboutsummaryrefslogtreecommitdiffstats
path: root/static/js/index.js
blob: b1a7167cd8bf339d2ad79b1b03f5f610c1f222ef (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
45
46
47
48
49
50
51
52
53
54
55
56
;(function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0](function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){
(function() {
  var fetchExchangeRate, g;

  g = typeof exports !== "undefined" && exports !== null ? exports : this;

  $(function() {
    fetchExchangeRate('ask');
    fetchExchangeRate('bid');
    $('#username').blur(function() {
      return $.get("/" + ($(this).val()) + "/exists", {
        username: $(this).val()
      }, function(data) {
        if (data === "true") {
          $('#username').prev().css('color', 'red').html('Username (taken)');
          return g.preventSubmit = true;
        } else {
          $('#username').prev().css('color', 'black').html('Username');
          return g.preventSubmit = false;
        }
      });
    });
    return $('#signup').submit(function() {
      if (g.preventSubmit) {
        return false;
      }
      return true;
    });
  });

  fetchExchangeRate = function(type) {
    var commission;
    commission = 0.015;
    if (type === 'bid') {
      commission *= -1;
    }
    return $.ajax({
      url: "/ticker?symbol=virtexCAD&type=" + type + "&amount=100",
      success: function(exchange) {
        if (exchange == null) {
          exchange = '??';
        }
        exchange = exchange - exchange * commission;
        return $("#" + type).html(exchange.toFixed(2));
      },
      error: function() {
        return $("#" + type).html('??');
      }
    });
  };

}).call(this);


},{}]},{},[1])
;