diff --git a/app.js b/app.js
index f3e9bfe..34a5752 100644
--- a/app.js
+++ b/app.js
@@ -407,68 +407,77 @@ app.use('/ext/getaddresstxs/:address/:start/:length', function(req, res) {
app.use('/ext/getsummary', function(req, res) {
// check if the getsummary api is enabled or else check the headers to see if it matches an internal ajax request from the explorer itself (TODO: come up with a more secure method of whitelisting ajax calls from the explorer)
if ((settings.api_page.enabled == true && settings.api_page.public_apis.ext.getsummary.enabled == true) || (req.headers['x-requested-with'] != null && req.headers['x-requested-with'].toLowerCase() == 'xmlhttprequest' && req.headers.referer != null && req.headers.accept.indexOf('text/javascript') > -1 && req.headers.accept.indexOf('application/json') > -1)) {
- lib.get_difficulty(function(difficulty) {
- difficultyHybrid = '';
-
- if (difficulty && difficulty['proof-of-work']) {
- if (settings.shared_pages.difficulty == 'Hybrid') {
- difficultyHybrid = 'POS: ' + difficulty['proof-of-stake'];
- difficulty = 'POW: ' + difficulty['proof-of-work'];
- } else if (settings.shared_pages.difficulty == 'POW')
- difficulty = difficulty['proof-of-work'];
- else
- difficulty = difficulty['proof-of-stake'];
- }
-
- lib.get_hashrate(function(hashrate) {
- lib.get_connectioncount(function(connections) {
- lib.get_blockcount(function(blockcount) {
+ lib.get_connectioncount(function(connections) {
+ lib.get_blockcount(function(blockcount) {
+ // check if this is a footer-only method that should only return the connection count and block count
+ if (req.headers['footer-only'] != null && req.headers['footer-only'] == 'true') {
+ // only return the connection count and block count
+ res.send({
+ connections: (connections ? connections : '-'),
+ blockcount: (blockcount ? blockcount : '-')
+ });
+ } else {
+ lib.get_hashrate(function(hashrate) {
db.get_stats(settings.coin.name, function (stats) {
lib.get_masternodecount(function(masternodestotal) {
- if (hashrate == 'There was an error. Check your console.')
- hashrate = 0;
+ lib.get_difficulty(function(difficulty) {
+ difficultyHybrid = '';
- // check if the masternode count api is enabled
- if (settings.api_page.public_apis.rpc.getmasternodecount.enabled == true && settings.api_cmds['getmasternodecount'] != null && settings.api_cmds['getmasternodecount'] != '') {
- // masternode count api is available
- var mn_total = 0;
- var mn_enabled = 0;
-
- if (masternodestotal) {
- if (masternodestotal.total)
- mn_total = masternodestotal.total;
-
- if (masternodestotal.enabled)
- mn_enabled = masternodestotal.enabled;
+ if (difficulty && difficulty['proof-of-work']) {
+ if (settings.shared_pages.difficulty == 'Hybrid') {
+ difficultyHybrid = 'POS: ' + difficulty['proof-of-stake'];
+ difficulty = 'POW: ' + difficulty['proof-of-work'];
+ } else if (settings.shared_pages.difficulty == 'POW')
+ difficulty = difficulty['proof-of-work'];
+ else
+ difficulty = difficulty['proof-of-stake'];
}
- res.send({
- difficulty: (difficulty ? difficulty : '-'),
- difficultyHybrid: difficultyHybrid,
- supply: (stats == null || stats.supply == null ? 0 : stats.supply),
- hashrate: hashrate,
- lastPrice: (stats == null || stats.last_price == null ? 0 : stats.last_price),
- connections: (connections ? connections : '-'),
- masternodeCountOnline: (masternodestotal ? mn_enabled : '-'),
- masternodeCountOffline: (masternodestotal ? Math.floor(mn_total - mn_enabled) : '-'),
- blockcount: (blockcount ? blockcount : '-')
- });
- } else {
- // masternode count api is not available
- res.send({
- difficulty: (difficulty ? difficulty : '-'),
- difficultyHybrid: difficultyHybrid,
- supply: (stats == null || stats.supply == null ? 0 : stats.supply),
- hashrate: hashrate,
- lastPrice: (stats == null || stats.last_price == null ? 0 : stats.last_price),
- connections: (connections ? connections : '-'),
- blockcount: (blockcount ? blockcount : '-')
- });
- }
+ if (hashrate == 'There was an error. Check your console.')
+ hashrate = 0;
+
+ // check if the masternode count api is enabled
+ if (settings.api_page.public_apis.rpc.getmasternodecount.enabled == true && settings.api_cmds['getmasternodecount'] != null && settings.api_cmds['getmasternodecount'] != '') {
+ // masternode count api is available
+ var mn_total = 0;
+ var mn_enabled = 0;
+
+ if (masternodestotal) {
+ if (masternodestotal.total)
+ mn_total = masternodestotal.total;
+
+ if (masternodestotal.enabled)
+ mn_enabled = masternodestotal.enabled;
+ }
+
+ res.send({
+ difficulty: (difficulty ? difficulty : '-'),
+ difficultyHybrid: difficultyHybrid,
+ supply: (stats == null || stats.supply == null ? 0 : stats.supply),
+ hashrate: hashrate,
+ lastPrice: (stats == null || stats.last_price == null ? 0 : stats.last_price),
+ connections: (connections ? connections : '-'),
+ masternodeCountOnline: (masternodestotal ? mn_enabled : '-'),
+ masternodeCountOffline: (masternodestotal ? Math.floor(mn_total - mn_enabled) : '-'),
+ blockcount: (blockcount ? blockcount : '-')
+ });
+ } else {
+ // masternode count api is not available
+ res.send({
+ difficulty: (difficulty ? difficulty : '-'),
+ difficultyHybrid: difficultyHybrid,
+ supply: (stats == null || stats.supply == null ? 0 : stats.supply),
+ hashrate: hashrate,
+ lastPrice: (stats == null || stats.last_price == null ? 0 : stats.last_price),
+ connections: (connections ? connections : '-'),
+ blockcount: (blockcount ? blockcount : '-')
+ });
+ }
+ });
});
});
});
- });
+ }
});
});
} else
diff --git a/views/layout.pug b/views/layout.pug
index d5fd88a..89cda80 100644
--- a/views/layout.pug
+++ b/views/layout.pug
@@ -192,66 +192,75 @@ html(lang='en')
}
}
function update_stats() {
- $.ajax({url: '/ext/getsummary', headers: {Accept: 'application/json, text/javascript, */*; q=0.01'}, success: function(json) {
- if (json.masternodeCountOnline == null)
- json.masternodeCountOnline = '-';
- if (json.masternodeCountOffline == null)
- json.masternodeCountOffline = '-';
+ var summary_headers = {
+ Accept: 'application/json, text/javascript, */*; q=0.01'
+ };
- var mnOnlineText = json.masternodeCountOnline+" node"+(json.masternodeCountOnline == 1 ? "" : "s")+" online";
- var mnOfflineText = json.masternodeCountOffline+" unreachable node"+(json.masternodeCountOffline == 1 ? "" : "s");
+ if (#{showPanels} == false)
+ summary_headers['footer-only'] = 'true';
- $("#masternodeCountOnline").text(json.masternodeCountOnline).prop("alt", mnOnlineText).prop("title", mnOnlineText).attr("data-original-title", mnOnlineText);
- $("#masternodeCountOffline").text(json.masternodeCountOffline).prop("alt", mnOfflineText).prop("title", mnOfflineText).attr("data-original-title", mnOfflineText);
- $("#spnMasternodeCountOnline").prop("alt", mnOnlineText).prop("title", mnOnlineText).attr("data-original-title", mnOnlineText);
- $("#spnMasternodeCountOffline").prop("alt", mnOfflineText).prop("title", mnOfflineText).attr("data-original-title", mnOfflineText);
- showTopPanelData('masternodepanel', 'masternodePanelLoading');
+ $.ajax({url: '/ext/getsummary', headers: summary_headers, success: function(json) {
+ if (#{showPanels} == true) {
+ if (json.masternodeCountOnline == null)
+ json.masternodeCountOnline = '-';
+ if (json.masternodeCountOffline == null)
+ json.masternodeCountOffline = '-';
- var supplyString = json.supply;
- var diffString = json.difficulty;
- var hashrateString = json.hashrate;
- var splitValue, splitParts;
+ var mnOnlineText = json.masternodeCountOnline+" node"+(json.masternodeCountOnline == 1 ? "" : "s")+" online";
+ var mnOfflineText = json.masternodeCountOffline+" unreachable node"+(json.masternodeCountOffline == 1 ? "" : "s");
- if (!isNaN(json.difficulty))
- diffString = Number(json.difficulty).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
- if (!isNaN(json.supply))
- supplyString = parseInt(parseFloat(json.supply).toFixed(0)).toLocaleString('en');
- if (!isNaN(json.hashrate))
- hashrateString = Number(json.hashrate).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
+ $("#masternodeCountOnline").text(json.masternodeCountOnline).prop("alt", mnOnlineText).prop("title", mnOnlineText).attr("data-original-title", mnOnlineText);
+ $("#masternodeCountOffline").text(json.masternodeCountOffline).prop("alt", mnOfflineText).prop("title", mnOfflineText).attr("data-original-title", mnOfflineText);
+ $("#spnMasternodeCountOnline").prop("alt", mnOnlineText).prop("title", mnOnlineText).attr("data-original-title", mnOnlineText);
+ $("#spnMasternodeCountOffline").prop("alt", mnOfflineText).prop("title", mnOfflineText).attr("data-original-title", mnOfflineText);
+ showTopPanelData('masternodepanel', 'masternodePanelLoading');
- $("#supply").text(supplyString);
- splitValue = Number(parseFloat(json.lastPrice).toFixed(8) * parseInt(parseFloat(json.supply).toFixed(0))).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
- splitParts = splitValue.split('.');
- showTopPanelData('supplypanel', 'supplyPanelLoading');
+ var supplyString = json.supply;
+ var diffString = json.difficulty;
+ var hashrateString = json.hashrate;
+ var splitValue, splitParts;
- $("#marketCap").html(splitParts[0] + '.' + splitParts[1] + '');
- showTopPanelData('marketCapPanel', 'marketCapPanelLoading');
+ if (!isNaN(json.difficulty))
+ diffString = Number(json.difficulty).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
+ if (!isNaN(json.supply))
+ supplyString = parseInt(parseFloat(json.supply).toFixed(0)).toLocaleString('en');
+ if (!isNaN(json.hashrate))
+ hashrateString = Number(json.hashrate).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
- splitParts = diffString.split('.');
- $("#difficulty").html(splitParts[0] + '.' + splitParts[1] + '');
+ $("#supply").text(supplyString);
+ splitValue = Number(parseFloat(json.lastPrice).toFixed(8) * parseInt(parseFloat(json.supply).toFixed(0))).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
+ splitParts = splitValue.split('.');
+ showTopPanelData('supplypanel', 'supplyPanelLoading');
- if (json.difficultyHybrid == null || json.difficultyHybrid == '')
- $("#difficultyHybrid").html('-');
- else {
- splitParts = json.difficultyHybrid.split('.');
- $("#difficultyHybrid").html(splitParts[0] + '.' + splitParts[1] + '');
+ $("#marketCap").html(splitParts[0] + '.' + splitParts[1] + '');
+ showTopPanelData('marketCapPanel', 'marketCapPanelLoading');
+
+ splitParts = diffString.split('.');
+ $("#difficulty").html(splitParts[0] + '.' + splitParts[1] + '');
+
+ if (json.difficultyHybrid == null || json.difficultyHybrid == '')
+ $("#difficultyHybrid").html('-');
+ else {
+ splitParts = json.difficultyHybrid.split('.');
+ $("#difficultyHybrid").html(splitParts[0] + '.' + splitParts[1] + '');
+ }
+
+ showTopPanelData('difficultypanel', 'difficultyPanelLoading');
+
+ if (hashrateString == null || hashrateString == '' || hashrateString == '-')
+ $("#hashrate").html('-');
+ else {
+ splitParts = hashrateString.split('.');
+ $("#hashrate").html(splitParts[0] + '.' + splitParts[1] + '');
+ }
+ showTopPanelData('hashratepanel', 'hashratePanelLoading');
+
+ splitValue = Number(json.lastPrice).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
+ splitParts = splitValue.split('.');
+ $("#lastPrice").html(splitParts[0] + '.' + splitParts[1] + '');
+ showTopPanelData('pricepanel', 'pricePanelLoading');
}
- showTopPanelData('difficultypanel', 'difficultyPanelLoading');
-
- if (hashrateString == null || hashrateString == '' || hashrateString == '-')
- $("#hashrate").html('-');
- else {
- splitParts = hashrateString.split('.');
- $("#hashrate").html(splitParts[0] + '.' + splitParts[1] + '');
- }
- showTopPanelData('hashratepanel', 'hashratePanelLoading');
-
- splitValue = Number(json.lastPrice).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
- splitParts = splitValue.split('.');
- $("#lastPrice").html(splitParts[0] + '.' + splitParts[1] + '');
- showTopPanelData('pricepanel', 'pricePanelLoading');
-
$("#lblConnections").text(json.connections + ' connections');
$("#lblBlockcount").text(json.blockcount + ' blocks');
}});
@@ -356,11 +365,11 @@ html(lang='en')
hideShowPanel('#{settings.panel3}', 'pnlThree');
hideShowPanel('#{settings.panel4}', 'pnlFour');
hideShowPanel('#{settings.panel5}', 'pnlFive');
- setInterval(function() {
- update_stats();
- }, 60000);
- update_stats();
}
+ setInterval(function() {
+ update_stats();
+ }, 60000);
+ update_stats();
fixFooterHeightAndPosition();
enableTooltips();
});