Hive coding #9

How to transfer Hive,HBD,EcencyPoints and HiveEngine Token?

by hive_coding

HTML

<html>
      <head>
        <script src="https://cdn.jsdelivr.net/npm/@hiveio/hive-js/dist/hive.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
         </head>
<body>

Username:<input type="text" id="username"><br/>
Amount/Betrag:<input type="text" id="amount"><br/>
Asset:<select id="asset">
<option value="HIVE">Hive</option>
<option value="HBD">HBD</option>
<option value="Ecency">EcencyPoints</option>
<option value="HE">Hive-Engine-Token</option>
</select><br/>
<div id="divmemo">
Memo (optional):<input type="text" id="memo" >
</div>
<div id="divHE" style="display:none">
Hive-Engin-Toke:<input type="text" id="symbol" >
</div>
<button id="btnSend">Send</button>

<script>
  var wif="NeverAddYourKeyonJSFiddle!";
  var from= "mein-senf-dazu"; 
  
$("#btnSend").click(function(){
console.log("x");
if($("#username").val()===""){
  	alert("Please add Username/ Bitte Username angeben");
    return;
  }
  
  	
 if($("#amount").val()===""){
  	alert("Please add amount/ Bitte Betrag angeben");
    return;
  }else{  
  	if(isNaN($("#amount").val())){
      alert("amount is not a number/ Betrag ist keine Zahl");
      return;    
      }
  }
  
  var amount= parseFloat($("#amount").val());
  var amount= parseFloat($("#amount").val());
  var to = $("#username").val()
  var memo=$("#memo").val();
  
	switch($("#asset").val()){
  
    case "HIVE":
				sendHiveHBD(amount, "HIVE",from, to, memo);
    break;

    case "HBD":
				sendHiveHBD(amount, "HBD",from, to, memo);
    break;

    case "Ecency":
				sendEcency(amount, from, to, memo);
    break;

    case "HE":
			sendHE(amount, $("#symbol").val(),from, to, memo);
    break;
  }

}); 


function sendHiveHBD(amount, asset, from, to, memo){

let fromattedAmount= hive.formatter.amount(amount, asset);

  hive.broadcast.transfer(wif, from, to, fromattedAmount, memo, function(err, result) {
    console.log(err, result);
  });

}

function sendHE(amount, asset, from,...