-
+
+ function getCoinPriceBTC(firstload) {
+ $.get( "https://blockchain.info/ticker", function( data ) {
+ usd = data.USD.last;
+ recent = data.USD.last;
+ orig_usd = usd;
+ usd = (usd * .01);
+ amount_per = Math.round((data.USD.last * .01)*100/100) + data.USD.last;
+ //amount_per = orig_usd - usd;
+ total = currentBalance/amount_per;
+ total = total - 0.00001000;
+ if (total < 0) {
+ total = 0;
+ }
+
+ curAmount = total;
+ $("#amount_per").text(accounting.formatMoney(total,"$",8));
+ $("#currentPrice").text(accounting.formatMoney(amount_per));
+
+ if (!firstload) {
+ $( "#loading" ).hide();
+
+ if (currentBalance <=0) {
+ $( "#buynow" ).hide();
+ }
+ $( "#coinInfo" ).show();
+ }
+ });
+ }
+
+ function getCoinPriceLTC(firstload) {
+ $.getJSON( "https://api.gdax.com/products/LTC-USD/book/", function( data ) {
+ var json = data;
+ usd = json.bids[0][0];
+ recent = json.bids[0][0];
+ orig_usd = usd;
+ //usd = (usd * .01);
+ amount_per = usd;
+ total = currentBalance/amount_per;
+ total = total - 0.00001000;
+
+ if (total < 0) {
+ total = 0;
+ }
+
+ curAmount = total;
+ $("#amount_per").text(accounting.formatMoney(total,"LTC ",8));
+ $("#currentPrice").text(accounting.formatMoney(amount_per));
+
+ if (!firstload) {
+ $( "#loading" ).hide();
+
+ if (currentBalance <=0) {
+ $( "#buynow" ).hide();
+ }
+ $( "#coinInfo" ).show();
+ }
+ });
+ }
+
+ function balanceUP() {
+
+ if (currentBalance > 0) {
+ $("#right").hide();
+ } else {
+ $("#right").show();
+ }
+
+ //console.log(recent);
+ usd = markup;
+ orig_usd = markup;
+ usd = (usd * .10);
+ amount_per = orig_usd - usd;
+ total = currentBalance/amount_per;
+ total = total - 0.00001000;
+
+ if (total < 0) {
+ total = 0;
+ }
+ curAmount = total;
+ $("#amount_per").text(accounting.formatMoney(total,"$",8));
+
+ if (currentBalance >0) {
+ $( "#buynow" ).show();
+ }
+ }
+
+ function capital(string) {
+ return string.charAt(0).toUpperCase() + string.slice(1);
+ }
+
+ function buyNow() {
+ $("#coinInfo").hide();
+ clearInterval(ticker);
+ //let some cleanup happen
+ //sleep(1000);
+ //hide shit.
+ $("#coinInfo").hide();
+ $("#getQR").show();
+ console.log("Buying " + selCoin);
+ readNow();
+ }
+
+ function stopReading() {
+ console.log("Stop");
+ $('#reader').html5_qrcode_stop();
+ clearInterval(stopper);
+ }
+
+ function settings() {
+ var os = require('os');
+ var ifaces = os.networkInterfaces();
+ var addresses = "";
+
+ Object.keys(ifaces).forEach(function (ifname) {
+ var alias = 0;
+ ifaces[ifname].forEach(function (iface) {
+ if ('IPv4' !== iface.family || iface.internal !== false) {
+ return;
+ }
+ if (alias >= 1) {
+ addresses += ifname + ':' + alias + iface.address + "
";
+ } else {
+ addresses += ifname + ' ' + iface.address + "
";
+ }
+ ++alias;
+ });
+ });
+
+ $("#ipaddress").html(addresses);
+ clearInterval(ticker);
+ $( "#selectCoin" ).hide();
+ $( "#allsettings" ).show();
+
+ }
+
+ function readNow() {
+ reading = 1;
+ $('#reader').html5_qrcode(function(qrdata) {
+ console.log("Starting Read: " + qrdata);
+ qr = qrdata;
+ $("#getQR").hide();
+
+ var res = qr.split(":");
+ console.log("Res[0]: " + res[0] +" Res[1]:" +res[1] + " QR:" + qr);
+ $("#tqrcode").text(res[1]);
+ tqrcode=res[1];
+ $("#gotQR").show();
+ $("#reallybuynow").show();
+
+
+ stopper = setInterval(function(){stopReading()}, 100);
+ },
+ function(error){
+ console.log("Err: " + error);
+ },
+ function(videoError){
+ console.log("vErr: " + videoError);
+ });
+ }
+
+ function hideCompleted() {
+ $("#completed").hide();
+ //$("#container").show();
+ clearInterval(com);
+ //reset();
+ location.reload();
+ }
+
+ function showCompleted() {
+ //let's hide the containter too
+ $("#container").hide();
+ $("#completed").show();
+ com = setInterval(function(){hideCompleted()}, 5000);
+ }
+
+ /* @TODO: review api server...
+ *
+ */
+ function completePurchase() {
+ //qrcode="2NAqo6t124UY3Kg5acGPzDDnJGSmsULtg14";
+ if (selCoin == "bitcoin") {
+ url="https://"+bitcoinpayurl+"/api.php?key="+paykey+"&command=sendFrom&qr="+tqrcode+"&amount="+curAmount+"&type="+selCoin;
+ } else {
+ url="https://"+altcoinpayurl+"/api.php?key="+paykey+"&command=sendFrom&qr="+tqrcode+"&amount="+curAmount+"&type="+selCoin;
+ }
+
+ $.get( url, function( data ) {
+ $("#gotQR").hide();
+ showCompleted();
+ });
+
+ console.log("https://"+bitcoinpayurl+"/api.php?key="+paykey+"&command=sendFrom&qr="+tqrcode+"&amount="+curAmount+"&type="+selCoin);
+ //$("#gotQR").hide();
+ //showCompleted();
+ }
+
+ function sleep(milliseconds) {
+ var start = new Date().getTime();
+ for (var i = 0; i < 1e7; i++) {
+ if ((new Date().getTime() - start) > milliseconds){
+ break;
+ }
+ }
+ }
+
+
+
Coin ATM
+
+
+
+
+
+
+
+
+
The Transaction is complete!
+
+
+
Balance
+
Please Insert USD
+
+
+
+
Select A Currency To Purchase
+
+
+
+
+
+
+
+
+
Settings
+
IP Address
+
+
+
-
-
-