Auto-update last updated date on applicable pages
-The index and movement pages auto-refresh the list of transactions but the last updated dates were not updated until the page was reloaded. This has been changed so that the last updated date now also auto-refreshes along with the table data
This commit is contained in:
@@ -644,6 +644,29 @@ app.use('/ext/getorphanlist/:start/:length', function(req, res) {
|
||||
res.end('This method is disabled');
|
||||
});
|
||||
|
||||
// get the last updated date for a particular section
|
||||
app.use('/ext/getlastupdated/:section', function(req, res) {
|
||||
// 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 (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) {
|
||||
// fix parameters
|
||||
if (req.params.section == null)
|
||||
req.params.section = '';
|
||||
|
||||
switch (req.params.section.toLowerCase()) {
|
||||
case 'blockchain':
|
||||
case 'movement':
|
||||
// lookup last updated date
|
||||
db.get_stats(settings.coin.name, function (stats) {
|
||||
res.json({'last_updated_date': stats.blockchain_last_updated});
|
||||
});
|
||||
break;
|
||||
default:
|
||||
res.send({error: 'Cannot find last updated date'});
|
||||
}
|
||||
} else
|
||||
res.end('This method is disabled');
|
||||
});
|
||||
|
||||
app.use('/ext/getnetworkchartdata', function(req, res) {
|
||||
db.get_network_chart_data(function(data) {
|
||||
if (data)
|
||||
|
||||
+25
-10
@@ -82,26 +82,41 @@ block content
|
||||
enableTooltips();
|
||||
}
|
||||
});
|
||||
var setting_reload_table_seconds = parseInt("#{settings.index_page.transaction_table.reload_table_seconds}");
|
||||
if (setting_reload_table_seconds > 0) {
|
||||
setInterval( function () {
|
||||
rtable.api().ajax.reload(null, false);
|
||||
}, (setting_reload_table_seconds * 1000) );
|
||||
}
|
||||
|
||||
if ('#{settings.index_page.page_header.show_last_updated}' == 'true') {
|
||||
var lastUpdatedDate = #{(last_updated == null || last_updated == '0' ? 0 : last_updated)};
|
||||
|
||||
function update_last_updated(lastUpdatedDate) {
|
||||
if (lastUpdatedDate != 0) {
|
||||
$('span#lastUpdatedDate').html(' ' + format_unixtime(lastUpdatedDate));
|
||||
|
||||
if (#{settings.shared_pages.date_time.enable_alt_timezone_tooltips} == true) {
|
||||
$('span#lastUpdatedDate').attr('data-bs-toggle', 'tooltip').attr('data-bs-placement', 'auto').attr('title', format_unixtime(lastUpdatedDate, true));
|
||||
$('span#lastUpdatedDate').attr('data-bs-toggle', 'tooltip').attr('data-bs-placement', 'auto').attr('title', format_unixtime(lastUpdatedDate, true)).attr('data-bs-original-title', format_unixtime(lastUpdatedDate, true));
|
||||
enableTooltips();
|
||||
}
|
||||
} else
|
||||
$('span#lastUpdatedDate').html(' N/A');
|
||||
}
|
||||
|
||||
var setting_reload_table_seconds = parseInt("#{settings.index_page.transaction_table.reload_table_seconds}");
|
||||
if (setting_reload_table_seconds > 0) {
|
||||
setInterval(function () {
|
||||
rtable.api().ajax.reload(null, false);
|
||||
}, (setting_reload_table_seconds * 1000));
|
||||
|
||||
if ('#{settings.index_page.page_header.show_last_updated}' == 'true') {
|
||||
setInterval(function () {
|
||||
$.ajax({url: '/ext/getlastupdated/blockchain', headers: { Accept: 'application/json, text/javascript, */*; q=0.01' }, success: function(json) {
|
||||
if (json != null && json.last_updated_date != null)
|
||||
update_last_updated(json.last_updated_date);
|
||||
else
|
||||
update_last_updated(0);
|
||||
}});
|
||||
}, (setting_reload_table_seconds * 1000));
|
||||
}
|
||||
}
|
||||
|
||||
if ('#{settings.index_page.page_header.show_last_updated}' == 'true') {
|
||||
var lastUpdatedDate = #{(last_updated == null || last_updated == '0' ? 0 : last_updated)};
|
||||
update_last_updated(lastUpdatedDate);
|
||||
}
|
||||
if (#{settings.shared_pages.page_header.page_title_image.enable_animation} == true && #{settings.index_page.page_header.show_img} == true)
|
||||
startRotateElement('img#header-img');
|
||||
});
|
||||
|
||||
+25
-11
@@ -81,26 +81,40 @@ block content
|
||||
}
|
||||
});
|
||||
|
||||
var setting_reload_table_seconds = parseInt("#{settings.movement_page.movement_table.reload_table_seconds}");
|
||||
if (setting_reload_table_seconds > 0) {
|
||||
setInterval( function () {
|
||||
rtable.api().ajax.reload(null, false);
|
||||
}, (setting_reload_table_seconds * 1000) );
|
||||
}
|
||||
|
||||
if ('#{settings.movement_page.page_header.show_last_updated}' == 'true') {
|
||||
var lastUpdatedDate = #{(last_updated == null || last_updated == '0' ? 0 : last_updated)};
|
||||
|
||||
function update_last_updated(lastUpdatedDate) {
|
||||
if (lastUpdatedDate != 0) {
|
||||
$('span#lastUpdatedDate').html(' ' + format_unixtime(lastUpdatedDate));
|
||||
|
||||
if (#{settings.shared_pages.date_time.enable_alt_timezone_tooltips} == true) {
|
||||
$('span#lastUpdatedDate').attr('data-bs-toggle', 'tooltip').attr('data-bs-placement', 'auto').attr('title', format_unixtime(lastUpdatedDate, true));
|
||||
$('span#lastUpdatedDate').attr('data-bs-toggle', 'tooltip').attr('data-bs-placement', 'auto').attr('title', format_unixtime(lastUpdatedDate, true)).attr('data-bs-original-title', format_unixtime(lastUpdatedDate, true));
|
||||
enableTooltips();
|
||||
}
|
||||
} else
|
||||
$('span#lastUpdatedDate').html(' N/A');
|
||||
}
|
||||
|
||||
var setting_reload_table_seconds = parseInt("#{settings.movement_page.movement_table.reload_table_seconds}");
|
||||
if (setting_reload_table_seconds > 0) {
|
||||
setInterval(function () {
|
||||
rtable.api().ajax.reload(null, false);
|
||||
}, (setting_reload_table_seconds * 1000));
|
||||
|
||||
if ('#{settings.movement_page.page_header.show_last_updated}' == 'true') {
|
||||
setInterval(function () {
|
||||
$.ajax({url: '/ext/getlastupdated/movement', headers: { Accept: 'application/json, text/javascript, */*; q=0.01' }, success: function(json) {
|
||||
if (json != null && json.last_updated_date != null)
|
||||
update_last_updated(json.last_updated_date);
|
||||
else
|
||||
update_last_updated(0);
|
||||
}});
|
||||
}, (setting_reload_table_seconds * 1000));
|
||||
}
|
||||
}
|
||||
|
||||
if ('#{settings.movement_page.page_header.show_last_updated}' == 'true') {
|
||||
var lastUpdatedDate = #{(last_updated == null || last_updated == '0' ? 0 : last_updated)};
|
||||
update_last_updated(lastUpdatedDate);
|
||||
}
|
||||
if (#{settings.shared_pages.page_header.page_title_image.enable_animation} == true && #{settings.movement_page.page_header.show_img} == true)
|
||||
startRotateElement('img#header-img');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user