first commit
This commit is contained in:
34
js/lastblock.js
Normal file
34
js/lastblock.js
Normal file
@@ -0,0 +1,34 @@
|
||||
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();
|
||||
});
|
||||
Reference in New Issue
Block a user