stable
This commit is contained in:
@@ -37,31 +37,18 @@
|
||||
});
|
||||
|
||||
$(window).scroll(function() {
|
||||
if (isInViewport(document.querySelector('footer')))
|
||||
{
|
||||
//blockchainExplorer.addBottomBlock();
|
||||
console.log("Scroll to footer detected !");
|
||||
}
|
||||
var element = document.getElementById('blockchain');
|
||||
var offset = element.getBoundingClientRect().top - element.offsetParent.getBoundingClientRect().top;
|
||||
const top = window.pageYOffset + window.innerHeight - offset;
|
||||
|
||||
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
|
||||
// blockchainExplorer.addBottomBlock();
|
||||
console.log("Scroll to footer detected !");
|
||||
}
|
||||
|
||||
$(".slideanim").each(function(){
|
||||
var pos = $(this).offset().top;
|
||||
var winTop = $(window).scrollTop();
|
||||
if (pos < winTop + 600) {
|
||||
blockchainExplorer.addBottomBlock();
|
||||
$(this).addClass("slide");
|
||||
}
|
||||
});
|
||||
|
||||
if (top === element.scrollHeight) {
|
||||
console.log("bottom");
|
||||
blockchainExplorer.addBottomBlock();
|
||||
}
|
||||
});
|
||||
|
||||
blockchainExplorer.init(0);
|
||||
showInfos();
|
||||
|
||||
//toggleInfos();
|
||||
});
|
||||
|
||||
var isInViewport = function (elem) {
|
||||
@@ -76,13 +63,7 @@
|
||||
|
||||
function showInfos()
|
||||
{
|
||||
var flag = 2*parseInt($('#mode_selector').val());
|
||||
|
||||
$('#blockchain').html('');
|
||||
|
||||
if ($('#mode_checkbox').is(":checked")) flag += 1;
|
||||
|
||||
blockchainExplorer.init(flag);
|
||||
blockchainExplorer.init(parseInt($('#mode_selector').val()));
|
||||
}
|
||||
|
||||
function toggleInfos()
|
||||
@@ -122,7 +103,7 @@
|
||||
<div class="col-sm-12 text-right">
|
||||
<br><small>An image for each block of the BTC Blockchain</small>
|
||||
<br><a href="nft.php">Click here to buy a block as an NFT</a>
|
||||
<br><select id="mode_selector" onchange="showInfos(this)">
|
||||
<br><select id="mode_selector" onchange="showInfos()">
|
||||
<option value=0>Full Blockchain Explorer</option>
|
||||
<option value=1>My special Blocks list</option>
|
||||
</select>
|
||||
@@ -134,14 +115,5 @@
|
||||
|
||||
<div id="blockchain" style="position:absolute;top:210px;width:100%"></div>
|
||||
|
||||
<div>
|
||||
Click to see more blocks
|
||||
</div>
|
||||
|
||||
<footer class="container-fluid bg-grey text-center slideanim">
|
||||
<a href="#myPage" title="To Top">
|
||||
<span class="glyphicon glyphicon-chevron-up"></span>
|
||||
</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+21
-22
@@ -75,14 +75,13 @@ blockchainExplorer = function(){
|
||||
_flag_nav = false;
|
||||
|
||||
blockName = _getblockNameFromHash(block.hash);
|
||||
// if (blockName != '') blockName = ' ( '+blockName+' )';
|
||||
|
||||
if (_mode > 1)
|
||||
if (block.hash == _liste_blocks['TOP'])
|
||||
{
|
||||
div_label = 'LAST';
|
||||
if (blockName == '') blockName = 'LAST';
|
||||
}
|
||||
if (blockName == '') blockName = block.height;
|
||||
|
||||
opacity='1.0';
|
||||
visibility='hidden';
|
||||
@@ -90,23 +89,20 @@ blockchainExplorer = function(){
|
||||
opacity='0.3';
|
||||
visibility='visible';
|
||||
}
|
||||
contenu += ' <div style="height:220px;width:100%;display:block;position:relative">';
|
||||
|
||||
contenu += '<div id="img_'+block.height+'" style="color:black;opacity:'+opacity+';margin-right:30pxo;height:220px">';
|
||||
contenu += ' <table class="block_infos" align="center" width="330px" height="220px" style="margin-top:3px;visibility:'+visibility+'">';
|
||||
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>block</td><td align="right"><b>'+blockName+'</b></td></tr>';
|
||||
contenu += ' <tr><td>timestamp</td><td align="right"><b>'+_formatDate(block.time)+'</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>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>';
|
||||
if (_mode != 3 ) contenu += ' <tr><td>fees</td><td align="right"><b>'+_precisionRound(block.topisto_fees).toFixed(4)+'</b></td></tr>';
|
||||
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 += ' </table>';
|
||||
contenu += '</div>';
|
||||
|
||||
contenu += ' </div>';
|
||||
|
||||
$('#info_'+div_label).html(contenu);
|
||||
|
||||
@@ -245,24 +241,24 @@ blockchainExplorer = function(){
|
||||
|
||||
// Récursivité pour précharger par paquets
|
||||
// Tant qu'on n'est pas sur le GENESIS
|
||||
if (data.height > 0)
|
||||
if (data.height > 0)
|
||||
switch(_mode)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
// Récursivité pour précharger par paquets
|
||||
_liste_blocks['BOTTOM'] = data.prev;
|
||||
// En mode "Full Blockchain", on suit le chainage
|
||||
_liste_blocks['BOTTOM'] = data.prev;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
_liste_blocks['BOTTOM'] = _known_blocks[_liste_blocks['LENGTH']-1].hash;
|
||||
case 1:
|
||||
// En mode "Blocks Connus", on prend le prochain de la liste
|
||||
_liste_blocks['BOTTOM'] = _known_blocks[_liste_blocks['LENGTH']-1].hash;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function _addBottomBlock()
|
||||
{
|
||||
{
|
||||
console.log('add '+_liste_blocks['BOTTOM']);
|
||||
|
||||
// Mettre les infos du block
|
||||
block_hash = '?block_hash='+_liste_blocks['BOTTOM'];
|
||||
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
||||
@@ -276,14 +272,15 @@ blockchainExplorer = function(){
|
||||
// Maintenir la Liste
|
||||
_maintenirListe(data);
|
||||
|
||||
if (_liste_blocks['LENGTH'] % 10) _addBottomBlock();
|
||||
if (data.height > 0)
|
||||
if (_liste_blocks['LENGTH'] % 5) _addBottomBlock();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function _initBlockchain(block_name)
|
||||
{
|
||||
var block_hash = '';
|
||||
var block_hash_url = 'data/getBlockInfo.php';
|
||||
|
||||
_liste_blocks = [];
|
||||
_liste_blocks['LENGTH'] = 0;
|
||||
@@ -291,17 +288,19 @@ blockchainExplorer = function(){
|
||||
$(document).scrollTop( $("#explorer").offset().top );
|
||||
$('#blockchain').html('');
|
||||
|
||||
if (block_name != 'LAST') block_hash = '?block_hash='+_getblocHashFromName(block_name);
|
||||
$.getJSON('data/getBlockInfo.php'+block_hash, function( data ) {
|
||||
|
||||
if (block_name != 'LAST') block_hash_url += '?block_hash='+_getblocHashFromName(block_name);
|
||||
|
||||
$.getJSON(block_hash_url, function( data ) {
|
||||
|
||||
div_label = data.height;
|
||||
_liste_blocks['TOP'] = data.hash;
|
||||
|
||||
_maintenirListe(data);
|
||||
|
||||
_addDivForBlock(div_label);
|
||||
_addInfoForBlock(data);
|
||||
|
||||
_maintenirListe(data);
|
||||
|
||||
// Cela fout le boxon pour l'instant
|
||||
// blockchainListener.addBlockHook(_addTopBlock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user