ruhul0

Fiverr

Apr 18th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function CustomAlert(){
  2. this.render = function(dialog){
  3. var winW = window.innerWidth;
  4. var winH = window.innerHeight;
  5. var dialogoverlay = document.getElementById('dialogoverlay');
  6. var dialogbox = document.getElementById('dialogbox');
  7. dialogoverlay.style.display = "block";
  8. dialogoverlay.style.height = winH+"px";
  9. dialogbox.style.left = (winW/2) - (550 * .5)+"px";
  10. dialogbox.style.top = "100px";
  11. dialogbox.style.display = "block";
  12. document.getElementById('dialogboxhead').innerHTML = "Transaction Confirmation";
  13. document.getElementById('dialogboxbody').innerHTML = dialog;
  14. document.getElementById('dialogboxfoot').innerHTML = '<button class="btn btn-warning" onclick="Alert.ok()">OK</button>';
  15. }
  16. this.ok = function(){
  17. document.getElementById('dialogbox').style.display = "none";
  18. document.getElementById('dialogoverlay').style.display = "none";
  19. }
  20. }
  21. var Alert = new CustomAlert();
  22.  
  23. function buy() {
  24.  
  25. var value = document.getElementById('ethAmountBuy').value;
  26.  
  27. tokenContract.buy({
  28. from: user_address,
  29. value: Eth.toWei(parseInt(value), 'ether'),
  30. gasPrice: gasprice
  31. })
  32. .then(txHash => eth.getTransactionSuccess(txHash))
  33. .then(receipt => {
  34. Alert.render(`Transaction Sent\nTx Hash: ${receipt.transactionHash}`)
  35. })
  36. .catch((err) => {
  37. console.log(err);
  38. })
  39. }
Advertisement
Add Comment
Please, Sign In to add comment