From 336f0e30dbf94267c574bec2649b58aa9456feb8 Mon Sep 17 00:00:00 2001 From: MEUNIER Thibaud Date: Thu, 11 Nov 2021 17:36:24 +0100 Subject: [PATCH] =?UTF-8?q?r=C3=A9activer=20le=20refesh=20du=20top=20block?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/blockexplorer.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/js/blockexplorer.js b/js/blockexplorer.js index 1e14318..178225c 100644 --- a/js/blockexplorer.js +++ b/js/blockexplorer.js @@ -75,8 +75,11 @@ blockchainExplorer = function(){ _flag_nav = false; blockName = _getblockNameFromHash(block.hash); - if (block.hash == _liste_blocks['TOP']) blockName = 'LAST BLOCK'; - if (blockName == '') blockName = 'height'; + if (block.hash == _liste_blocks['TOP']) { + blockName = 'LAST BLOCK'; + if (_mode == 1) div_label = 'LAST'; + } + if (blockName == '') blockName = 'block'; else blockName = ''+blockName+''; visibility='hidden'; @@ -210,20 +213,28 @@ blockchainExplorer = function(){ function _addTopBlock(data, flag = false) { + var old_hash = _liste_blocks['TOP']; + + if (old_hash == data.hash) return false; + if (flag) return "ajouterTopBlock"; // Maintenir la liste des blocks _liste_blocks['TOP'] = data.hash; _liste_blocks['BLOCK_'+data.height] = data.hash; - // Ajouter un div - if (_mode < 2) _addDivForBlock(data.height,true); - + // RafraƮchir l'ancien block TOP + if (_mode == 0) { + $.getJSON('data/getBlockInfo.php?block_hash='+old_hash, function( old ) { + _addInfoForBlock(old); + }); + _addDivForBlock(data.height,true); + } + // Mettre les infos dans le div _addInfoForBlock(data); topistoConsole.log('Last Block on top : '+data.hash); - } function _maintenirListe(data){ @@ -289,6 +300,10 @@ blockchainExplorer = function(){ $.getJSON(block_hash_url, function( data ) { div_label = data.height; + if (_mode == 1) + if (block_name == 'LAST') + div_label = 'LAST'; + _liste_blocks['TOP'] = data.hash; _addDivForBlock(div_label); @@ -298,7 +313,7 @@ blockchainExplorer = function(){ _maintenirListe(data); // Cela fout le boxon pour l'instant - // blockchainListener.addBlockHook(_addTopBlock); + blockchainListener.addBlockHook(_addTopBlock); }); return true;