aboutsummaryrefslogtreecommitdiffstats
path: root/public/js/deposit.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2014-08-08 07:11:56 -0700
committerAdam Soltys <[email protected]>2014-08-08 07:11:56 -0700
commit561ab2d01e059da44c0e5b34f5527fe946a1448c (patch)
tree6165fcae53610081d5f7f3ba8a5b4e56a57d14fb /public/js/deposit.js
parente1464288b2f53fd4c200d64df9a085dbb0ca80b7 (diff)
downloadcoinos-server-561ab2d01e059da44c0e5b34f5527fe946a1448c.tar.gz
coinos-server-561ab2d01e059da44c0e5b34f5527fe946a1448c.zip
Use connect-assets for js and css
Diffstat (limited to 'public/js/deposit.js')
-rw-r--r--public/js/deposit.js102
1 files changed, 0 insertions, 102 deletions
diff --git a/public/js/deposit.js b/public/js/deposit.js
deleted file mode 100644
index 3bb5bf23..00000000
--- a/public/js/deposit.js
+++ /dev/null
@@ -1,102 +0,0 @@
-(function() {
- var ADDRESS_FAIL, EXCHANGE_FAIL, SOCKET_FAIL, clear, fail, g, get, setupSocket;
-
- EXCHANGE_FAIL = "Error fetching exchange rate";
-
- SOCKET_FAIL = "Error connecting to payment server";
-
- ADDRESS_FAIL = "Invalid address";
-
- g = typeof exports !== "undefined" && exports !== null ? exports : this;
-
- $(function() {
- g.address || (g.address = '1VAnbtCAnYccECnjaMCPnWwt81EHCVgNr');
- setupSocket();
- setupQR();
- return displayQR('bitcoin:' + g.address);
- });
-
- setupSocket = function() {
- g.address = "1VAnbtCAnYccECnjaMCPnWwt81EHCVgNr";
- setTimeout(setupSocket, 10000);
- if (!(g.websocket && g.websocket.readyState === 1)) {
- g.websocket = new WebSocket("ws://api.blockchain.info:8335/inv");
- g.websocket.onopen = function() {
- return g.websocket.send('{"op":"addr_sub", "addr":"' + g.address + '"}');
- };
- g.websocket.onerror = g.websocket.onclose = function() {
- return fail(SOCKET_FAIL);
- };
- return g.websocket.onmessage = function(e) {
- var from_address, received, results, total;
- results = eval('(' + e.data + ')');
- from_address = '';
- total = 0;
- received = 0;
- $.each(results.x.out, function(i, v) {
- if (v.addr === g.address) {
- return received += v.value;
- }
- });
- $.each(results.x.inputs, function(i, v) {
- from_address = v.prev_out.addr;
- if (v.prev_out.addr === g.address) {
- return input -= v.prev_out.value;
- }
- });
- return $.get("/issue/" + received, function(data) {
- return $('#received').text(data);
- });
- };
- }
- };
-
- fail = function(msg) {
- g.errors.push(msg);
- g.errors = g.errors.uniq();
- $('#calculator').hide();
- return $('#error').show().html(g.errors.toString());
- };
-
- clear = function(msg) {
- var i;
- i = g.errors.indexOf(msg);
- if (i >= 0) {
- g.errors.splice(i, 1);
- }
- if (g.errors.length > 0) {
- return $('#error').show().html(g.errors.toString());
- } else {
- $('#error').hide();
- return $('#calculator').fadeIn('slow');
- }
- };
-
- get = function(name) {
- var regex, regexS, results;
- name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
- regexS = "[\\?&]" + name + "=([^&#]*)";
- regex = new RegExp(regexS);
- results = regex.exec(window.location.search);
- if (results === null) {
- return "";
- } else {
- return decodeURIComponent(results[1].replace(/\+/g, " "));
- }
- };
-
- Array.prototype.uniq = function() {
- var key, output, value, _i, _ref, _results;
- output = {};
- for (key = _i = 0, _ref = this.length; 0 <= _ref ? _i < _ref : _i > _ref; key = 0 <= _ref ? ++_i : --_i) {
- output[this[key]] = this[key];
- }
- _results = [];
- for (key in output) {
- value = output[key];
- _results.push(value);
- }
- return _results;
- };
-
-}).call(this);