diff --git a/data/getEmptyBlocksList.php b/data/getEmptyBlocksList.php new file mode 100644 index 0000000..6b12a7c --- /dev/null +++ b/data/getEmptyBlocksList.php @@ -0,0 +1,48 @@ + diff --git a/index.php b/index.php index c81b180..39fe36c 100644 --- a/index.php +++ b/index.php @@ -98,6 +98,7 @@

diff --git a/js/blockexplorer.js b/js/blockexplorer.js index 6df86da..a8ae644 100644 --- a/js/blockexplorer.js +++ b/js/blockexplorer.js @@ -2,6 +2,7 @@ blockchainExplorer = function(){ // Init array var _known_blocks = null; + var _empty_blocks = null; var _liste_blocks = []; var _classes = ['bg-grey-even','bg-grey-odd']; var _cur_class = 0; @@ -76,9 +77,12 @@ blockchainExplorer = function(){ blockName = _getblockNameFromHash(block.hash); if (block.hash == _liste_blocks['TOP']) { - blockName = 'LAST BLOCK'; - if (_mode == 1) - div_label = 'LAST'; + if (_mode != 2) + { + blockName = 'LAST BLOCK'; + if (_mode == 1) + div_label = 'LAST'; + } } if (blockName == '') blockName = 'block'; else blockName = ''+blockName+''; @@ -105,6 +109,8 @@ blockchainExplorer = function(){ $('#info_'+div_label).html(contenu); + if (_mode == 2) _cur_methode = 'emptybot'; + downloadingImage.onload = function(){ var div0 = document.getElementById('img_'+div_label); div0.style.backgroundImage = "url(" + this.src + ")"; @@ -263,7 +269,15 @@ blockchainExplorer = function(){ } //_liste_blocks['BOTTOM'] = _known_blocks[_liste_blocks['LENGTH']-1].hash; break; - } + case 2: + // En mode "Blocks Vides", on prend le prochain de la liste + _liste_blocks['BOTTOM'] = _empty_blocks[0][0]; + for(i = 0; i < _empty_blocks.length; i++){ + if (data.height == _empty_blocks[i][1]) + _liste_blocks['BOTTOM'] = _empty_blocks[i+1][0]; + } + break; + } if (data.height > 0) if (_liste_blocks['LENGTH'] % 15) @@ -298,6 +312,9 @@ blockchainExplorer = function(){ $('#blockchain').html(''); + // Mode "Empty Blocks" + if (_mode == 2) block_hash_url += '?block_hash='+_empty_blocks[0][0]; + else if (block_name != 'LAST') block_hash_url += '?block_hash='+_getblocHashFromName(block_name); $.getJSON(block_hash_url, function( data ) { @@ -352,6 +369,13 @@ blockchainExplorer = function(){ return true; }); } + if (_empty_blocks == null) + { + $.getJSON('data/getEmptyBlocksList.php', function( data ) { + _empty_blocks = data; + return true; + }); + } } function _init(mode, infos) @@ -375,6 +399,13 @@ blockchainExplorer = function(){ }); } + if (_empty_blocks == null) + { + $.getJSON('data/getEmptyBlocksList.php', function( data ) { + _empty_blocks = data; + return true; + }); + } return _initBlockchain('LAST'); } @@ -441,6 +472,11 @@ blockchainExplorer = function(){ return true; } + function _initEmptyBlocks() + { + _init(2,false); + } + function _showBlockAllMethod(blockname) { allMethod = [ @@ -480,6 +516,8 @@ blockchainExplorer = function(){ initOneBlock : _initOneBlock, initBlockSelector : _initBlockSelector, + initEmptyBlocks : _initEmptyBlocks, + toggleInfos: _toggleInfos, getLength: _getLength, diff --git a/nft.php b/nft.php index 8cbe2ec..7f41cc1 100644 --- a/nft.php +++ b/nft.php @@ -43,7 +43,7 @@ if ( window.scrollY > (2200+lastScroll)) { lastScroll = window.scrollY; - if ($('#blockSelector').val() == 'FULL') + if ($('#blockSelector').val() == 'EMPTY') blockchainExplorer.addBottomBlock(); } }); @@ -66,7 +66,10 @@ function selectBlock() { lastScroll = 0; - blockchainExplorer.initOneBlock($('#blockSelector').val()); + if ($('#blockSelector').val() != 'EMPTY') + blockchainExplorer.initOneBlock($('#blockSelector').val()); + else + blockchainExplorer.initEmptyBlocks(); } @@ -103,6 +106,7 @@