diff options
| author | Adam Soltys <[email protected]> | 2016-11-23 15:32:32 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2016-12-26 14:22:39 -0800 |
| commit | 5c91e5d45afaa22a71bfcdbd4c956a8993388bdb (patch) | |
| tree | 4a15b18e05a5fd13c19aec35954f2d430748a6e0 | |
| parent | a38665ae8273da58e657317026bb07f51d4ae731 (diff) | |
| download | coinos-server-5c91e5d45afaa22a71bfcdbd4c956a8993388bdb.tar.gz coinos-server-5c91e5d45afaa22a71bfcdbd4c956a8993388bdb.zip | |
Remove whitespace
| -rw-r--r-- | public/js/calculator.coffee | 25 | ||||
| -rw-r--r-- | public/js/calculator.js | 9 | ||||
| -rw-r--r-- | src/app.coffee | 24 |
3 files changed, 27 insertions, 31 deletions
diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee index 7dfb6186..75192596 100644 --- a/public/js/calculator.coffee +++ b/public/js/calculator.coffee @@ -13,7 +13,7 @@ g.transactions = [] $(-> $.ajax( - url: $('#user').val() + '.json', + url: $('#user').val() + '.json', dataType: 'json', success: (data) -> g.user = data @@ -70,8 +70,8 @@ $(-> ) $('#received').click(-> window.location = "/#{g.user.username}/report") - $('#slide').click(-> - $('#controls').slideToggle() + $('#slide').click(-> + $('#controls').slideToggle() $(this).find('i').toggleClass('fa-sort-up').toggleClass('fa-sort-down') ) ) @@ -83,7 +83,7 @@ setup = -> g.user.symbol or= 'quadrigacx' g.user.unit or= 'BTC' - if g.user.title + if g.user.title $('#title').html("<a href='/#{g.user.username}/edit'>#{g.user.title}</a>").show() if g.user.logo @@ -107,7 +107,7 @@ setup = -> fetchExchangeRate = -> $.ajax( url: "ticker?currency=#{g.user.currency}&symbol=#{g.user.symbol}&type=bid", - success: (exchange) -> + success: (exchange) -> if exchange? clear(EXCHANGE_FAIL) else @@ -149,7 +149,6 @@ updateTotal = -> $('#total').html(total.toString()) - # size = $('#calculator').width() * 0.7 size = 300 $('#qr').css('height', size) @@ -160,7 +159,7 @@ updateTotal = -> clearTimeout(g.timeout) g.timeout = setTimeout(-> $('#qr').html('') - new QRCode('qr', + new QRCode('qr', text: "bitcoin:#{g.user.address}?amount=#{g.amount_requested.toString()}" width: size height: size @@ -175,7 +174,7 @@ listen = -> fail(SOCKET_FAIL) if g.attempts > 3 g.blockchain = new WebSocket(API_URL) - g.blockchain.onopen = -> + g.blockchain.onopen = -> if g.blockchain.readyState is 1 g.attempts = 0 clear(SOCKET_FAIL) @@ -195,18 +194,16 @@ listen = -> g.blockchain.onmessage = (e) -> tx = JSON.parse(e.data) - amount = 0 - txid = tx.hash - return if txid == g.last - g.last = txid + return if tx.hash == g.last_seen + g.last_seen = tx.hash for output in tx.outputs - if (output.addresses[0] == g.user.address) + if (output.addresses[0] == g.user.address) amount += output.value / 100000000 - logTransaction(txid, amount) + logTransaction(tx.hash, amount) logTransaction = (txid, amount) -> if $('#received').is(":hidden") and amount >= g.amount_requested diff --git a/public/js/calculator.js b/public/js/calculator.js index c85c9bb3..6e71b56a 100644 --- a/public/js/calculator.js +++ b/public/js/calculator.js @@ -201,14 +201,13 @@ return listen(); }; return g.blockchain.onmessage = function(e) { - var amount, j, len, output, ref, tx, txid; + var amount, j, len, output, ref, tx; tx = JSON.parse(e.data); amount = 0; - txid = tx.hash; - if (txid === g.last) { + if (tx.hash === g.last_seen) { return; } - g.last = txid; + g.last_seen = tx.hash; ref = tx.outputs; for (j = 0, len = ref.length; j < len; j++) { output = ref[j]; @@ -216,7 +215,7 @@ amount += output.value / 100000000; } } - return logTransaction(txid, amount); + return logTransaction(tx.hash, amount); }; } }; diff --git a/src/app.coffee b/src/app.coffee index 75b182ec..1fc2099c 100644 --- a/src/app.coffee +++ b/src/app.coffee @@ -18,10 +18,10 @@ sessionStore = new RedisStore(require('./redis').host, ttl: 172800) proxyContext = '/blockcypher' -proxyOptions = +proxyOptions = target: 'https://api.blockcypher.com' changeOrigin: true - pathRewrite: + pathRewrite: '^/blockcypher/': '/' onProxyReq: (proxyReq, req, res) -> symbol = if '?' in proxyReq.path then '&' else '?' @@ -54,7 +54,7 @@ app.use(passport.session()) authorize = (req, res, next) -> if req.params.user is req.user?.username or req.user?.username is 'admin' - return next() + return next() req.session.redirect = req.path res.redirect('/login') @@ -66,7 +66,7 @@ cache = (req, res, next) -> do fetchRates = -> request("https://api.bitcoinaverage.com/exchanges/all", (error, response, body) -> - try + try require('util').isDate(JSON.parse(body).timestamp) file = 'public/js/rates.json' stream = fs.createWriteStream(file) @@ -81,9 +81,9 @@ require('./bcoin').init(app) app.get('/', cache, sessions.new) app.get('/address', cache, (req, res) -> - res.render('address', + res.render('address', layout: 'layout', - js: (-> global.js), + js: (-> global.js), css: (-> global.css) ) ) @@ -95,12 +95,12 @@ app.get('/ticker', cache, (req, res) -> req.query.symbol ||= 'quadrigacx' req.query.type ||= 'bid' - try + try exchange = JSON.parse(data)[req.query.currency][req.query.symbol]['rates'][req.query.type].toString() - catch e + catch e exchange = "0" - res.writeHead(200, + res.writeHead(200, 'Content-Length': exchange.length, 'Content-Type': 'text/plain') res.write(exchange) @@ -109,10 +109,10 @@ app.get('/ticker', cache, (req, res) -> ) app.get('/tips', cache, (req, res) -> - res.render('tips', + res.render('tips', notice: true, layout: 'layout', - js: (-> global.js), + js: (-> global.js), css: (-> global.css) ) ) @@ -143,7 +143,7 @@ app.get('/:user', cache, users.show) app.use((err, req, res, next) -> res.status(500) - res.send('An error occurred'); + res.send('An error occurred') console.error(err.stack) res.end() ) |
