$(document).ready(function() { var testElements = document.getElementsByClassName('longbalance'); Array.prototype.filter.call(testElements, function(testElement){ testElement.innerHTML = Number((testElement.innerHTML)/100000000).toFixed(2) }); var testElements = document.getElementsByClassName('bdbalance'); Array.prototype.filter.call(testElements, function(testElement){ testElement.innerHTML = Number((testElement.innerHTML)).toFixed(2) }); var percents = document.getElementsByClassName('percent'); Array.prototype.filter.call(percents, function(testElement){ atId = testElement.id var atBalance = Number(document.getElementById('atbalance-'+atId).innerHTML); var askBalance = Number(document.getElementById('askbalance-'+atId).innerHTML); var percent = 0; if (atBalance >0) { percent = 100 * atBalance/askBalance; } percentOne = percent if (percent>79) percentOne = 79 document.getElementById(atId).style = "width:"+percentOne+"%!important" document.getElementById('percent-text-'+atId).innerHTML = percent.toFixed(2) }); }) var updateValue; updateValue = function() { document.getElementById('result').innerHTML = '
Saving...
'; var amount = document.getElementById('amount').value * 100000000 var hexA = Number(amount).toString(16).toLowerCase(); var finalA = ''; if ((hexA.length%2) !=0 ) { hexA="0"+hexA } for (var i=hexA.length-1;i>0;i=i-2) { finalA = finalA + hexA[i-1] + hexA[i] } var finalLength = finalA.length for (var i=0; i< 16 - finalLength; i=i+1) { finalA = finalA } var weeksA = document.getElementById('duration').value var fee = "30"; var type = "qrowdfund" var code = "350003020000002500000000350004030000002103000000010000004f3501030400000033040304000000352501050000001b050000004a3506030600000035070304000000320a0301070000000200000000000000330204060000001a2400000001070000000100000000000000320b033203043502030400000033040304000000352501050000001b05000000f235070304000000320b033203041a7c000000" var data = ""; var tags = document.getElementById('tags').value; var initialAmount = "30"; var minActivationAmount = "20"; var dpages = "1" var usPages = "0" var csPages = "0" var data = weeksA + finalA var jsonstring = { "creator": document.getElementById('select-name').value, "name": document.getElementById('at-name').value ,"description": document.getElementById('short-description').value, "fee": fee ,"type":type, "code":code, "quantity": initialAmount, "code":code, "data":data, "dpages":dpages, "cspages":csPages, "uspages":usPages, "tags":tags, "minActivationAmount":minActivationAmount}; $.post( "/index/api.html", { type: 'post', apiurl: '/at', json: JSON.stringify(jsonstring) }) .done( function(data) { if (data.type == 'success') { document.getElementById('result').innerHTML = "
AT deployed successful.
"; } else if(data.type == 'apicallerror') { document.getElementById('result').innerHTML = "
ERROR
"+data.errordetail+"
"; } else if (data.type == 'error') { try { var error = JSON.parse(data.error); message = error.message; } catch (e) { message = data.error; } document.getElementById('result').innerHTML = "
An error occurred while submitting the payment.
"+message+"
"; } else { document.getElementById('result').innerHTML = "
Unknown response:
"+data+"
"; } }) .fail( function(xhr, textStatus, errorThrown) { document.getElementById('result').innerHTML = '
ERROR
'+xhr.responseText+'
'; }); document.getElementById('result').innerHTML = '
Sending...
'; };