You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
796 B

function logBlockHash(leblock)
{
  console.log('Last Block detected : '+leblock.hash);
}
var last_block = null;
var last_block_hooks = [logBlockHash];
var last_block_refresh_flag = true;
function getLastBlockInfo()
{
  $.get( "data/getBlockInfo.php", function( data ) {
    if ((last_block == null)||(last_block.hash != data.hash))
    {      
      if (last_block_refresh_flag && (last_block != null)) 
        last_block_refresh_flag = window.confirm('New block detected, apply change ?');
      
      last_block = data;
      if (last_block_refresh_flag)
      {
        last_block_hooks.forEach(function(element) {
          element(last_block);
        });
      }
    } 
  }, "json" );
  setTimeout(getLastBlockInfo, 30000);
}
$(document).ready(function() {
  getLastBlockInfo();
});