Hive coding #12

Hivejs: how to get delegations from a User to other user (outgoing delegations)

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>
        <!-- CSS only -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
      </head>
      <body>
    <div class="row">
      <div class="col-xs-8 offset-sm-1">
            <div class="row">
            <div class="col-sm-6">
            Username: <input type="text" id="username">
            <button id="show">Load Delegations</button></div>
          </div>
              <h2>Ausgabe/Output:</h2>
             <div id="log2"></div>
             <div id="log"></div>

        </div>
    </div>
    <script>
    
    String.prototype.log = function () {
      $("<div>"+this+"</div>").appendTo("#log");
    };

var total_vesting_fund_hive;
var total_vesting_shares;

$("#show").click(function() {
         hive.api.getVestingDelegations($("#username").val(), '', 1000, function(err, result) {
          for(i=0;i<result.length;i++){

              (result[i].delegatee+":"+hive.formatter.amount(hive.formatter.vestToHive(result[i].vesting_shares, total_vesting_shares, total_vesting_fund_hive),"HP")).log();

          }
        });
});

hive.api.getDynamicGlobalProperties(function(err, result) {
 total_vesting_fund_hive= result.total_vesting_fund_hive;
 total_vesting_shares= result.total_vesting_shares;
 
});

        </script>
      </body>
    </html>