Bootstrap Table

by jimkennelly

HTML

<link rel="stylesheet" href="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.css">
<script src="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.js"></script>
<table data-toggle="table" data-show-footer="true" data-url="/gh/get/response.json/wenzhixin/bootstrap-table/tree/master/docs/data/data1/">
  <thead>
    <tr>
      <th data-field="name">Name</th>
      <th data-field="stargazers_count" data-footer-formatter="formatTotalStars">Stars</th>
      <th data-field="forks_count" data-footer-formatter="formatTotalForks">Forks</th>
      <th data-field="description">Description</th>
    </tr>
  </thead>
</table>

JavaScript

function formatTotalStars(data, a) {
  var a=this;
  debugger;
  
  var total = 0;
  $.each(data, function(i, row) {
    total += Number(row.stargazers_count);
  });
  return total;
}

function formatTotalForks(data) {
  var total = 0;
  $.each(data, function(i, row) {
    total += Number(row.forks_count);
  });
  return total;
}