diff options
| author | Adam Soltys <[email protected]> | 2012-09-05 19:23:03 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2012-09-05 19:23:03 -0700 |
| commit | b25d11b7f45990e8857c8b930c93a63bcb46d624 (patch) | |
| tree | 34beb73e9b55e86132abcb5c79d3b6fdb8494c70 /index.html | |
| download | coinos-server-b25d11b7f45990e8857c8b930c93a63bcb46d624.tar.gz coinos-server-b25d11b7f45990e8857c8b930c93a63bcb46d624.zip | |
Initial commit
Diffstat (limited to 'index.html')
| -rw-r--r-- | index.html | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/index.html b/index.html new file mode 100644 index 00000000..deeddb8f --- /dev/null +++ b/index.html @@ -0,0 +1,92 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>Bitcoin Payment Calculator</title> + <script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script> + <script language="javascript" type="text/javascript"> + $(function() { + var websocket = new WebSocket("ws://api.blockchain.info:8335/inv"); + var exchange = 0; + var total = 0; + var received = 0; + + websocket.onopen = function() { + websocket.send('{"op":"addr_sub", "addr":"1PcXspQbZWxUkS9bHcbgMUsb8HsUzP5noT"}'); + } + + websocket.onmessage = function(e) { + var results = eval('(' + e.data + ')'); + + $.each(results.x.out, function(i, v) { + if (v.addr == '1PcXspQbZWxUkS9bHcbgMUsb8HsUzP5noT') { + received += v.value / 100000000; + } + }); + + $.each(results.x.inputs, function(i, v) { + if (v.prev_out.addr == '1PcXspQbZWxUkS9bHcbgMUsb8HsUzP5noT') { + input -= v.prev_out.value / 100000000; + } + }); + + $('#status').html('Received: ' + received.toString()); + if (total <= received) { + $('#status').css('color', 'green'); + } + } + + $.getJSON('ticker', function (data) { + exchange = data.return.last.value; + $('#exchange').html(exchange); + updateTotal(); + }); + + $('#owing').keyup(updateTotal); + $('#owing').focus(); + + function updateTotal() { + var owing = parseFloat($('#owing').val()); + total = owing / exchange; + total = Math.ceil(total * 10000) / 10000; + if (!$.isNumeric(total)) total = ''; + $('#total').html(total.toString()); + } + }); + </script> + </head> + <style> + body, input { font-family: 'Arial'; font-size: 20px; } + #total { font-size: 32px; } + #status { color: red } + </style> + <body> + <img src="banner.jpg" /> + + <div> + $<input type="text" id="owing" value="0" size="4" /> CAD @ + <span id="exchange"></span> + BTC/CAD + </div> + + <br /> + + <div> + <span>Please send</span> + <strong id="total">0.0</strong> + bitcoins to: + + <br /><br /> + + 1PcXspQbZWxUkS9bHcbgMUsb8HsUzP5noT + + <br /> + + <img id="qr" src="https://chart.googleapis.com/chart?cht=qr&chl=bitcoin:1PcXspQbZWxUkS9bHcbgMUsb8HsUzP5noT&chs=177x177&chld=H" width="300" height="300" /> + + <br /> + + <span id="status">Waiting for Payment</span> + </div> + </body> +</html> |
