Skip to content

Commit

Permalink
1.0.2 update
Browse files Browse the repository at this point in the history
Height in URL param, API page
  • Loading branch information
aivve committed Mar 18, 2017
1 parent 9d18ba8 commit 91a57c3
Show file tree
Hide file tree
Showing 10 changed files with 216 additions and 89 deletions.
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var blockTargetInterval = 240;
var coinUnits = 1000000000000;
var symbol = 'KRB';
var refreshDelay = 30000;
var ver = "1.0.1";
var ver = "1.0.2";
// pools stats by MainCoins
var networkStat = {
"krb": [
Expand Down
20 changes: 18 additions & 2 deletions css/themes/white/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,25 @@ code {
border-top-color: #c9e0e9;
text-align: center;
}
#blocks_rows > tr > td:nth-child(2) {
text-align: left;
}

#content {
margin-bottom: 200px;
z-index: 1;
background-color: #FDFDFD;
}

footer {
background-color: #FDFDFD;
position: relative !important;
background-color: #333333;
color: #FDFDFD;
position: fixed;
bottom: 0;
z-index: -1;
padding: 30px 0;
width: 100%;
height: 200px;
}

.scrollup{
Expand Down
17 changes: 11 additions & 6 deletions en/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<link rel="shortcut icon" href="../favicon.ico">
<link rel="icon" type="image/icon" href="favicon.ico" >
<link rel="icon" type="image/icon" href="../favicon.ico" >
<title>Karbowanec (&#1180;) [KRB] Block Explorer</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.4.0/jquery.timeago.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-sparklines/2.1.2/jquery.sparkline.min.js"></script>
<link href="/css/themes/dark/style.css" rel="stylesheet">
<link href="/css/themes/white/style.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="//fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css">
Expand Down Expand Up @@ -223,6 +223,10 @@
<li><a class="hot_link" data-page="pools.html" href="#pools">
<i class="fa fa-gavel" aria-hidden="true"></i> Pools
</a></li>

<li><a class="hot_link" data-page="api.html" href="#api">
<i class="fa fa-code" aria-hidden="true"></i> API
</a></li>

<li><a class="hot_link" href="/">
<i class="fa fa-language" aria-hidden="true"></i> Ukrainian
Expand Down Expand Up @@ -404,13 +408,14 @@
});
</script>

<div id="content">
<div class="container">

<div class="container">

<div id="page"></div>
<div id="page"></div>

<p id="loading" class="text-center"><i class="fa fa-circle-o-notch fa-spin"></i></p>
<p id="loading" class="text-center"><i class="fa fa-circle-o-notch fa-spin"></i></p>

</div>
</div>

<footer>
Expand Down
21 changes: 21 additions & 0 deletions en/pages/api.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<h2><i class="fa fa-code" aria-hidden="true"></i> API <small id="paymend_id" style="word-break: break-all;"></small></h2>



<div class="container">
<div class="row">
<div class="col-lg-12">

<h4>Supported APIs</h4>

<ul>
<li><strong><a href="/q/hashrate">hashrate</a></strong> &ndash; current estimated network hashrate</li>
<li><strong><a href="/q/height">height</a></strong> &ndash; current height (incl. genesis block)</li>
<li><strong><a href="/q/reward">reward</a></strong> &ndash; current block reward</li>
<li><strong><a href="/q/supply">supply</a></strong> &ndash; total available supply</li>
</ul>


</div>
</div>
</div>
45 changes: 25 additions & 20 deletions en/pages/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ <h3 class="panel-title"><i class="fa fa-tasks fa-fw" aria-hidden="true"></i> Sta
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="Estimated network hash rate. Calculated by current difficulty."><i class="fa fa-tachometer"></i> Hash Rate: <span id="networkHashrate"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="Ratio at which at the current hashing speed blocks will be mined with 4 minutes interval."><i class="fa fa-unlock-alt"></i> Difficulty: <span id="networkDifficulty"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="The number of transactions in the network (excluding coinbase, i.e. reward for mined blocks)."><i class="fa fa fa-exchange"></i> Transactions: <span id="networkTransactions"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="Current Base Reward (for last mined block)."><i class="fa fa-money"></i> Reward: <span id="currentReward"></span></a></li>
<li><a href="#" data-toggle="tooltip" data-placement="top" data-original-title="Total Karbo supply in circulation."><i class="fa fa-money"></i> Supply: <span id="totalCoins"></span></a></li>
</ul>
</div>
Expand Down Expand Up @@ -60,9 +61,10 @@ <h3 class="panel-title"><i class="fa fa-chain fa-fw" aria-hidden="true"></i> Rec
<thead>
<tr>
<th><i class="fa fa-bars"></i> Height</th>
<th><i class="fa fa-clock-o"></i> Date &amp; time</th>
<th><i class="fa fa-archive"></i> Size</th>
<th><i class="fa fa-paw"></i> Block Hash</th>
<th><i class="fa fa-clock-o"></i> Date & time</th>
<th><i class="fa fa-unlock-alt"></i> Difficulty</th>
<th><i class="fa fa-bars"></i> Transactions</th>
</tr>
</thead>
Expand All @@ -85,9 +87,7 @@ <h3 class="panel-title"><i class="fa fa-chain fa-fw" aria-hidden="true"></i> Rec
if (xhrGetBlocks) xhrGetBlocks.abort();
},
init: function(){
renderLastBlock();
renderInitialBlocks();
getPoolTransactions();

},
update: function(){
updateText('networkHeight', lastStats.height.toString());
Expand Down Expand Up @@ -135,6 +135,7 @@ <h3 class="panel-title"><i class="fa fa-chain fa-fw" aria-hidden="true"></i> Rec
success: function(data){
block = data.result.block;
updateText('totalCoins', getReadableCoins(block.alreadyGeneratedCoins,2));
updateText('currentReward', getReadableCoins(block.baseReward,4));
}
});
}
Expand All @@ -161,12 +162,17 @@ <h3 class="panel-title"><i class="fa fa-chain fa-fw" aria-hidden="true"></i> Rec
renderBlocks(data.result.blocks);
}
});
});

});

function renderInitialBlocks(){
if (xhrGetBlocks) xhrGetBlocks.abort();

var loadHeight;

if (urlParam('height'))
loadHeight = parseInt(urlParam('height'));
else
loadHeight = lastStats.last_known_block_index;

xhrGetBlocks = $.ajax({
url: api + '/json_rpc',
Expand All @@ -176,7 +182,7 @@ <h3 class="panel-title"><i class="fa fa-chain fa-fw" aria-hidden="true"></i> Rec
id: "test",
method:"f_blocks_list_json",
params: {
height: lastStats.last_known_block_index
height: loadHeight
}
}),
dataType: 'json',
Expand All @@ -187,23 +193,20 @@ <h3 class="panel-title"><i class="fa fa-chain fa-fw" aria-hidden="true"></i> Rec
});
};





function getBlockRowElement(block, jsonString){


var row = document.createElement('tr');
row.setAttribute('data-json', jsonString);
row.setAttribute('data-height', block.height);
row.setAttribute('id', 'blockRow' + block.height);
row.setAttribute('title', block.hash);
var dateTime = new Date(block.timestamp * 1000).toISOString();
var columns =
'<td>' + block.height + '</td>' +
'<td>' + block.cumul_size + '</td>' +
'<td>' + formatBlockLink(block.hash) + '</td>' +
'<td>' + formatDate(block.timestamp) + '</td>' +
'<td>' + formatDate(block.timestamp) + ' (<time class="timeago" datetime="'+dateTime+'"></time>)</td>' +
'<td>' + block.cumul_size + '</td>' +
'<td>' + formatBlockLink(block.hash) + '</td>' +
'<td>' + block.difficulty + '</td>' +
'<td>' + block.tx_count + '</td>';

row.innerHTML = columns;
Expand Down Expand Up @@ -240,12 +243,13 @@ <h3 class="panel-title"><i class="fa fa-chain fa-fw" aria-hidden="true"></i> Rec
break;
}
}
if (!inserted)
if (!inserted) {
$blocksRows.append(blockElement);
}
}

}
}
$("time.timeago").timeago();
}


// Karbovanets MemPool Transactions
Expand Down Expand Up @@ -287,13 +291,14 @@ <h3 class="panel-title"><i class="fa fa-chain fa-fw" aria-hidden="true"></i> Rec
var row;
var row = document.createElement('tr');
var columns =
'<td>' + formatDate(timestamp) + '</td>' +
'<td>' + formatDate(timestamp) + ' (<span class="mtx-ago"></span>)' + '</td>' +
'<td>' + getReadableCoins(amount, 4, true) + '</td>' +
'<td>' + getReadableCoins(fee, 4, true) + '</td>' +
'<td>' + size + '</td>' +
'<td>' + formatPaymentLink(hash) + '</td>';
row.innerHTML = columns;
txsRows.append(row);
txsRows.prepend(row);
$(row).find('.mtx-ago').timeago('update', new Date(block.timestamp * 1000).toISOString());
}
});
}
Expand Down
30 changes: 19 additions & 11 deletions en/pages/pools.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@
text-align: center;
}

#pools_header > tr > th:first-child,
#pools_rows > tr > td:first-child {
text-align: left;
}

#pools_header > tr > th:last-child,
#pools_rows > tr > td:last-child {
text-align: left;
}
</style>

<div class="container">
Expand All @@ -32,7 +38,7 @@
<th><i class="fa fa-tachometer"></i> Hashrate</th>
<th><i class="fa fa-group"></i> Miners</th>
<th><i class="fa fa-money"></i> Total Fee</th>
<th><i class="fa fa-clock-o"></i> Last block found</th>
<th><i class="fa fa-clock-o"></i> Last Block Found</th>
</tr>
</thead>
<tbody id="pools_rows">
Expand All @@ -54,7 +60,7 @@
<div class="container">
<div class="row">
<div class="col-lg-12">
<small style="font-size: 0.55em;">* Total known pools hashrate.</small>
<small>* Total known pools hashrate.</small>
</div>
</div>
</div>
Expand All @@ -73,12 +79,15 @@
$.getJSON(url + '/stats', (data, textStatus, jqXHR) => {
var d = new Date(parseInt(data.pool.lastBlockFound));
var datestring = ("0" + d.getDate()).slice(-2) + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" + d.getFullYear() + " " + ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2);
$('#pools_rows').append('<tr><td id=host'+host+'><a target=blank href=http://'+host+'>'+host+'</a></td><td id=height'+host+'>'+data.network.height+'</td><td id=hashrate'+host+'>'+data.pool.hashrate+'&nbsp;H/s</td><td id=miners'+host+'>'+data.pool.miners+'</td><td id=totalFree'+host+'>'+calculateTotalFree(data)+'%</td><td id=lastFound'+host+'>'+datestring+'</td><</tr>');

var agostring = $.timeago(d);

$('#pools_rows').append('<tr><td id=host'+host+'><a target=blank href=http://'+host+'>'+host+'</a></td><td id=height'+host+'>'+data.network.height+'</td><td id=hashrate'+host+'>'+data.pool.hashrate+'&nbsp;H/s</td><td id=miners'+host+'>'+data.pool.miners+'</td><td id=totalFree'+host+'>'+calculateTotalFree(data)+'%</td><td><span id=lastFound'+host+'>'+datestring+'</span> (<span class="timeago" id="ago-'+host+'">'+agostring+'</span>)</td><</tr>');

totalHashrate += parseInt(data.pool.hashrate);
updateText('totalPoolsHashrate', getReadableHashRateString(totalHashrate) + '/sec');
poolNames.push(host);
poolHashrates.push(parseInt(data.pool.hashrate));

window.colors.push(getRandomColor());

});
Expand All @@ -92,14 +101,8 @@
destroy: function(){
},
init: function(){



},
update: function(){



}
};

Expand Down Expand Up @@ -166,8 +169,13 @@
updateText('miners'+host, data.pool.miners);
updateText('totalFree'+host, calculateTotalFree(data)+'%');
var d = new Date(parseInt(data.pool.lastBlockFound));

var datestring = ("0" + d.getDate()).slice(-2) + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" + d.getFullYear() + " " + ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2);
updateText('lastFound'+host, datestring);

var agostring = $.timeago(d);
updateText('ago-'+host, agostring);

totalHashrate += parseInt(data.pool.hashrate);
updateText('totalPoolsHashrate', getReadableHashRateString(totalHashrate) + '/sec');
});
Expand All @@ -178,7 +186,7 @@

});

}, 300000);
}, 240000);


function refreshChart() {
Expand Down
Loading

0 comments on commit 91a57c3

Please sign in to comment.