/* Node Status */ function check_status(identificator) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { var obj = JSON.parse(xhr.responseText); var state = obj.state; switch(state) { case 'NON_EXISTING': document.getElementById(identificator+'_status').innerText = 'Not initialized'; document.getElementById(identificator+'_status').classList.add("badge-danger"); break; case 'LOCKED': document.getElementById(identificator+'_status').innerText = 'Locked'; document.getElementById(identificator+'_status').classList.add("badge-warning"); break; case 'UNLOCKED': document.getElementById(identificator+'_status').innerText = 'Running'; document.getElementById(identificator+'_status').classList.add("badge-success"); break; case 'RPC_ACTIVE': document.getElementById(identificator+'_status').innerText = 'Running'; document.getElementById(identificator+'_status').classList.add("badge-success"); break; case 'SERVER_ACTIVE': document.getElementById(identificator+'_status').innerText = 'Running'; document.getElementById(identificator+'_status').classList.add("badge-success"); break; default: document.getElementById(identificator+'_status').innerText = 'Unknown'; document.getElementById(identificator+'_status').classList.add("badge-secondary"); break; } } } xhr.open("GET", "https://"+identificator+".bitnoder.com/api/status.php", true); xhr.send(); } /* Check Payment Functions */ function check_invoice(payreq) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { var obj = JSON.parse(xhr.responseText); var settled = obj.settled; if(settled) { window.location.href = "https://bitnoder.com/account/success/"; } } } xhr.open("GET", "https://bitnoder.com/ci.php?payreq="+encodeURIComponent(payreq), true); xhr.send(); } function check_balance(address, requested) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if(xhr.readyState == 4 && xhr.status == 200) { var xmlDoc = xhr.responseXML; var data = xmlDoc.getElementsByTagName("data")[0]; if(data.getAttribute("balance") >= requested) { window.location.href = "https://bitnoder.com/account/success/"; } } } xhr.open("GET", "https://peername.net/api/getbalance.php?address="+encodeURIComponent(address), true); xhr.send(); } /* Copy Button */ function copyField(id) { var field = document.getElementById(id); field.focus(); field.setSelectionRange(0, field.value.length); document.execCommand("copy"); } /* Affiliates */ function createCookie(name, value, days) { var date, expires; if(days) { date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString(); } else { expires = ""; } document.cookie = name + "=" + value + expires + "; path=/"; } var site_url = location.href.split('#'); if(typeof(site_url[1]) != "undefined" && /^\d+$/.test(site_url[1])) { createCookie('aff_id', site_url[1], 90); }