aboutsummaryrefslogtreecommitdiffstats
path: root/public/js/index.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2014-07-15 00:44:25 -0700
committerAdam Soltys <[email protected]>2014-07-15 00:44:25 -0700
commit5255f026a68be987dbccc191900752d7e9daf1af (patch)
tree62e17454a7d364b39d9a7adca27fcfec32bd4a78 /public/js/index.js
parent3b565f4f4dcea55779e00493e7cf507cf8392010 (diff)
downloadcoinos-server-5255f026a68be987dbccc191900752d7e9daf1af.tar.gz
coinos-server-5255f026a68be987dbccc191900752d7e9daf1af.zip
Add menu, change view engine, use Grunt
Diffstat (limited to 'public/js/index.js')
-rw-r--r--public/js/index.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/public/js/index.js b/public/js/index.js
new file mode 100644
index 00000000..7b799c1e
--- /dev/null
+++ b/public/js/index.js
@@ -0,0 +1,51 @@
+(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);