Fix broken footer stats on pages without panels
-The update_stats() function is now called again from all pages even when not displaying panels to fix an oversight with the earlier change to allow removal of panels from any page -Reorganized the structure and order of calls within the /ext/getsummary api to allow for returning just the connection and block counts for pages that have show_panels set to false
This commit is contained in:
@@ -407,6 +407,19 @@ 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_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) {
|
||||
lib.get_difficulty(function(difficulty) {
|
||||
difficultyHybrid = '';
|
||||
|
||||
@@ -420,11 +433,6 @@ app.use('/ext/getsummary', function(req, res) {
|
||||
difficulty = difficulty['proof-of-stake'];
|
||||
}
|
||||
|
||||
lib.get_hashrate(function(hashrate) {
|
||||
lib.get_connectioncount(function(connections) {
|
||||
lib.get_blockcount(function(blockcount) {
|
||||
db.get_stats(settings.coin.name, function (stats) {
|
||||
lib.get_masternodecount(function(masternodestotal) {
|
||||
if (hashrate == 'There was an error. Check your console.')
|
||||
hashrate = 0;
|
||||
|
||||
@@ -469,6 +477,7 @@ app.use('/ext/getsummary', function(req, res) {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
} else
|
||||
|
||||
+11
-2
@@ -192,7 +192,15 @@ html(lang='en')
|
||||
}
|
||||
}
|
||||
function update_stats() {
|
||||
$.ajax({url: '/ext/getsummary', headers: {Accept: 'application/json, text/javascript, */*; q=0.01'}, success: function(json) {
|
||||
var summary_headers = {
|
||||
Accept: 'application/json, text/javascript, */*; q=0.01'
|
||||
};
|
||||
|
||||
if (#{showPanels} == false)
|
||||
summary_headers['footer-only'] = 'true';
|
||||
|
||||
$.ajax({url: '/ext/getsummary', headers: summary_headers, success: function(json) {
|
||||
if (#{showPanels} == true) {
|
||||
if (json.masternodeCountOnline == null)
|
||||
json.masternodeCountOnline = '-';
|
||||
if (json.masternodeCountOffline == null)
|
||||
@@ -251,6 +259,7 @@ html(lang='en')
|
||||
splitParts = splitValue.split('.');
|
||||
$("#lastPrice").html(splitParts[0] + '.<span class="decimal">' + splitParts[1] + '</span>');
|
||||
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();
|
||||
}
|
||||
fixFooterHeightAndPosition();
|
||||
enableTooltips();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user