|
|
@ -17,8 +17,8 @@ blockchainExplorer = function(){ |
|
|
function _getblockNameFromHash(hash)
|
|
|
function _getblockNameFromHash(hash)
|
|
|
{
|
|
|
{
|
|
|
var retour = '';
|
|
|
var retour = '';
|
|
|
if (_
liste
_blocks != null)
|
|
|
|
|
|
_
liste
_blocks.forEach(function(item){
|
|
|
|
|
|
|
|
|
if (_
known
_blocks != null)
|
|
|
|
|
|
_
known
_blocks.forEach(function(item){
|
|
|
if (hash == item.hash) retour = item.name;
|
|
|
if (hash == item.hash) retour = item.name;
|
|
|
});
|
|
|
});
|
|
|
return retour;
|
|
|
return retour;
|
|
|
@ -27,9 +27,10 @@ blockchainExplorer = function(){ |
|
|
function _getblocHashFromName(name)
|
|
|
function _getblocHashFromName(name)
|
|
|
{
|
|
|
{
|
|
|
var retour = '';
|
|
|
var retour = '';
|
|
|
_liste_blocks.forEach(function(item){
|
|
|
|
|
|
if (name == item.name) retour = item.hash;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
if (_known_blocks != null)
|
|
|
|
|
|
_known_blocks.forEach(function(item){
|
|
|
|
|
|
if (name == item.name) retour = item.hash;
|
|
|
|
|
|
});
|
|
|
return retour;
|
|
|
return retour;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -37,14 +38,21 @@ blockchainExplorer = function(){ |
|
|
{
|
|
|
{
|
|
|
var contenu = '';
|
|
|
var contenu = '';
|
|
|
var downloadingImage = new Image();
|
|
|
var downloadingImage = new Image();
|
|
|
|
|
|
var div_label = block.height;
|
|
|
|
|
|
|
|
|
_cur_class = 1 - _cur_class;
|
|
|
_cur_class = 1 - _cur_class;
|
|
|
|
|
|
|
|
|
blockName = _getblockNameFromHash(block.hash);
|
|
|
blockName = _getblockNameFromHash(block.hash);
|
|
|
if (blockName != '') blockName = ' ( '+blockName+' )';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (blockName != '') blockName = ' ( '+blockName+' )';
|
|
|
|
|
|
|
|
|
|
|
|
if (_mode > 1)
|
|
|
|
|
|
if (block.hash == _liste_blocks['TOP'])
|
|
|
|
|
|
{
|
|
|
|
|
|
div_label = 'LAST';
|
|
|
|
|
|
if (blockName == '') blockName = 'LAST';
|
|
|
|
|
|
}
|
|
|
contenu += ' <div style="height:220px;width:100%;display:block;position:absolute">';
|
|
|
contenu += ' <div style="height:220px;width:100%;display:block;position:absolute">';
|
|
|
if (_mode != 0)
|
|
|
|
|
|
|
|
|
if (
(
_mode
% 2)
!= 0)
|
|
|
{
|
|
|
{
|
|
|
contenu += '<div style="color:black;opacity:1.0;margin-right:30px">';
|
|
|
contenu += '<div style="color:black;opacity:1.0;margin-right:30px">';
|
|
|
// contenu += ' <h2> <span style="font-size:12px">block</span> '+block.height+blockName+'</h2>';
|
|
|
// contenu += ' <h2> <span style="font-size:12px">block</span> '+block.height+blockName+'</h2>';
|
|
|
@ -52,20 +60,21 @@ blockchainExplorer = function(){ |
|
|
contenu += ' <table width="100%" style="margin-top:3px">';
|
|
|
contenu += ' <table width="100%" style="margin-top:3px">';
|
|
|
//contenu += ' <tr><td>hash</td><td align="right"><b>'+block.hash+'</b></td></tr>';
|
|
|
//contenu += ' <tr><td>hash</td><td align="right"><b>'+block.hash+'</b></td></tr>';
|
|
|
//contenu += ' <tr><td>index</td><td align="right"><b>'+block.block_index+'</b></td></tr>';
|
|
|
//contenu += ' <tr><td>index</td><td align="right"><b>'+block.block_index+'</b></td></tr>';
|
|
|
|
|
|
if (_mode == 3 ) contenu += ' <tr><td>name</td><td align="right"><b>'+blockName+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>height</td><td align="right"><b>'+block.height+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>height</td><td align="right"><b>'+block.height+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>timestamp</td><td align="right"><b>'+block.time+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>timestamp</td><td align="right"><b>'+block.time+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>nonce</td><td align="right"><b>'+block.nonce+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>nonce</td><td align="right"><b>'+block.nonce+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>nb tx</td><td align="right"><b>'+block.n_tx+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>nb tx</td><td align="right"><b>'+block.n_tx+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>outputs</td><td align="right"><b>'+_precisionRound(block.topisto_outputs).toFixed(4)+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>outputs</td><td align="right"><b>'+_precisionRound(block.topisto_outputs).toFixed(4)+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>inputs</td><td align="right"><b>'+_precisionRound(block.topisto_inputs).toFixed(4)+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>inputs</td><td align="right"><b>'+_precisionRound(block.topisto_inputs).toFixed(4)+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>fees</td><td align="right"><b>'+_precisionRound(block.topisto_fees).toFixed(4)+'</b></td></tr>';
|
|
|
|
|
|
|
|
|
if (_mode != 3 )
contenu += ' <tr><td>fees</td><td align="right"><b>'+_precisionRound(block.topisto_fees).toFixed(4)+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>reward</td><td align="right"><b>'+_precisionRound(block.topisto_reward).toFixed(4)+'</b></td></tr>';
|
|
|
contenu += ' <tr><td>reward</td><td align="right"><b>'+_precisionRound(block.topisto_reward).toFixed(4)+'</b></td></tr>';
|
|
|
contenu += ' </table>';
|
|
|
contenu += ' </table>';
|
|
|
contenu += '</div>';
|
|
|
contenu += '</div>';
|
|
|
}
|
|
|
}
|
|
|
contenu += ' </div>';
|
|
|
contenu += ' </div>';
|
|
|
|
|
|
|
|
|
$('#info_'+
b
l
ock.height
).html(contenu);
|
|
|
|
|
|
|
|
|
$('#info_'+
div_la
b
e
l
).html(contenu);
|
|
|
|
|
|
|
|
|
contenu = '';
|
|
|
contenu = '';
|
|
|
contenu += '<div id="img_'+block.height+'" style="';
|
|
|
contenu += '<div id="img_'+block.height+'" style="';
|
|
|
@ -79,7 +88,7 @@ blockchainExplorer = function(){ |
|
|
contenu += 'z-index: -1; ';
|
|
|
contenu += 'z-index: -1; ';
|
|
|
contenu += '"></div>'
|
|
|
contenu += '"></div>'
|
|
|
|
|
|
|
|
|
$('#info_'+
b
l
ock.height
).append(contenu);
|
|
|
|
|
|
|
|
|
$('#info_'+
div_la
b
e
l
).append(contenu);
|
|
|
|
|
|
|
|
|
downloadingImage.onload = function(){
|
|
|
downloadingImage.onload = function(){
|
|
|
|
|
|
|
|
|
@ -95,7 +104,7 @@ blockchainExplorer = function(){ |
|
|
div0.style.backgroundRepeat = "no-repeat";
|
|
|
div0.style.backgroundRepeat = "no-repeat";
|
|
|
div0.style.backgroundPosition = "center";
|
|
|
div0.style.backgroundPosition = "center";
|
|
|
div0.style.backgroundSize = "auto 100%";
|
|
|
div0.style.backgroundSize = "auto 100%";
|
|
|
if (
_mode
==
1) div0.style.opacity=0.3;
|
|
|
|
|
|
|
|
|
if (
(
_mode
%2)
==
1) div0.style.opacity=0.3;
|
|
|
|
|
|
|
|
|
flag_nav = true;
|
|
|
flag_nav = true;
|
|
|
|
|
|
|
|
|
@ -211,7 +220,7 @@ blockchainExplorer = function(){ |
|
|
_liste_blocks['BLOCK_'+data.height] = data.hash;
|
|
|
_liste_blocks['BLOCK_'+data.height] = data.hash;
|
|
|
|
|
|
|
|
|
// Ajouter un div
|
|
|
// Ajouter un div
|
|
|
_addDivForBlock(data.height,true);
|
|
|
|
|
|
|
|
|
if (_mode < 2)
_addDivForBlock(data.height,true);
|
|
|
|
|
|
|
|
|
// Mettre les infos dans le div
|
|
|
// Mettre les infos dans le div
|
|
|
_addInfoForBlock(data);
|
|
|
_addInfoForBlock(data);
|
|
|
@ -226,18 +235,32 @@ blockchainExplorer = function(){ |
|
|
block_hash = '?block_hash='+_liste_blocks['BOTTOM'];
|
|
|
block_hash = '?block_hash='+_liste_blocks['BOTTOM'];
|
|
|
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
|
|
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
|
|
|
|
|
|
|
|
_liste_blocks['BOTTOM'] = data.prev;
|
|
|
|
|
|
_liste_blocks['BLOCK_'+data.height] = data.hash;
|
|
|
|
|
|
_liste_blocks['LENGTH'] += 1;
|
|
|
|
|
|
|
|
|
|
|
|
// Ajouter un div
|
|
|
|
|
|
_addDivForBlock(data.height, false);
|
|
|
|
|
|
|
|
|
// Ajouter un div
|
|
|
|
|
|
_addDivForBlock(data.height, false);
|
|
|
|
|
|
|
|
|
// Mettre les infos dans le div
|
|
|
|
|
|
_addInfoForBlock(data);
|
|
|
|
|
|
|
|
|
// Mettre les infos dans le div
|
|
|
|
|
|
_addInfoForBlock(data);
|
|
|
|
|
|
|
|
|
// Récursivité pour précharger par paquets
|
|
|
|
|
|
if (_liste_blocks['LENGTH'] % 10) _addBottomBlock();
|
|
|
|
|
|
|
|
|
_liste_blocks['BLOCK_'+data.height] = data.hash;
|
|
|
|
|
|
_liste_blocks['LENGTH'] += 1;
|
|
|
|
|
|
|
|
|
|
|
|
switch(_mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
// Récursivité pour précharger par paquets
|
|
|
|
|
|
if (data.height > 0)
|
|
|
|
|
|
_liste_blocks['BOTTOM'] = data.prev;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
if (data.height > 0)
|
|
|
|
|
|
_liste_blocks['BOTTOM'] = _known_blocks[_liste_blocks['LENGTH']-1].hash;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_liste_blocks['LENGTH'] % 10) _addBottomBlock();
|
|
|
|
|
|
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -245,18 +268,35 @@ blockchainExplorer = function(){ |
|
|
{
|
|
|
{
|
|
|
var block_hash = '';
|
|
|
var block_hash = '';
|
|
|
|
|
|
|
|
|
|
|
|
_liste_blocks = [];
|
|
|
|
|
|
_liste_blocks['LENGTH'] = 0;
|
|
|
|
|
|
|
|
|
$(document).scrollTop( $("#explorer").offset().top );
|
|
|
$(document).scrollTop( $("#explorer").offset().top );
|
|
|
$('#blockchain').html('');
|
|
|
$('#blockchain').html('');
|
|
|
|
|
|
|
|
|
if (block_name != 'LAST') block_hash = '?block_hash='+_getblocHashFromName(block_name);
|
|
|
if (block_name != 'LAST') block_hash = '?block_hash='+_getblocHashFromName(block_name);
|
|
|
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
|
|
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
|
|
|
|
|
|
|
|
_liste_blocks['BOTTOM'] = data.prev;
|
|
|
|
|
|
_liste_blocks['TOP'] = data.hash;
|
|
|
_liste_blocks['TOP'] = data.hash;
|
|
|
_liste_blocks['BLOCK_'+data.height] = data.hash;
|
|
|
_liste_blocks['BLOCK_'+data.height] = data.hash;
|
|
|
_liste_blocks['LENGTH'] += 1;
|
|
|
_liste_blocks['LENGTH'] += 1;
|
|
|
|
|
|
|
|
|
_addDivForBlock(data.height);
|
|
|
|
|
|
|
|
|
div_label = data.height;
|
|
|
|
|
|
switch(_mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
// Récursivité pour précharger par paquets
|
|
|
|
|
|
_liste_blocks['BOTTOM'] = data.prev;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
div_label = 'LAST';
|
|
|
|
|
|
_liste_blocks['BOTTOM'] = _known_blocks[0].hash;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_addDivForBlock(div_label);
|
|
|
_addInfoForBlock(data);
|
|
|
_addInfoForBlock(data);
|
|
|
|
|
|
|
|
|
blockchainListener.addBlockHook(_addTopBlock);
|
|
|
blockchainListener.addBlockHook(_addTopBlock);
|
|
|
@ -288,8 +328,6 @@ blockchainExplorer = function(){ |
|
|
if (_known_blocks == null)
|
|
|
if (_known_blocks == null)
|
|
|
{
|
|
|
{
|
|
|
$.getJSON('data/getKnownBlocksList.php', function( data ) {
|
|
|
$.getJSON('data/getKnownBlocksList.php', function( data ) {
|
|
|
_liste_blocks = [];
|
|
|
|
|
|
_liste_blocks['LENGTH'] = 0;
|
|
|
|
|
|
|
|
|
|
|
|
_known_blocks = data;
|
|
|
_known_blocks = data;
|
|
|
_known_blocks.sort(function(a,b){
|
|
|
_known_blocks.sort(function(a,b){
|
|
|
|