php-mpos/public/templates/mpos/global/navjs.tpl
Sebastian Grewe 9485b3f9d6 [ADDED] Possibility to disable navbar live updates
* Added new admin options: disable_navbar and disable_navbar_api
* Removes LIVE STATS from navigation list
* Removes live updates on Pool General Statistics page
* Added system load checks to getnavbardata API call

This will help to decrease load on high-volume servers at the cost of
losing live status.

Fixes #1014 once merged.
2013-12-23 21:38:21 +01:00

78 lines
2.3 KiB
Smarty

<script>
{literal}
$(document).ready(function(){
var g1, g2;
// Ajax API URL
var url = "{/literal}{$smarty.server.PHP_SELF}?page=api&action=getnavbardata{literal}";
// Store our data globally
var storedHashrate=[];
var storedWorkers=[];
g1 = new JustGage({
id: "mr",
value: parseFloat({/literal}{$GLOBAL.workers}{literal}).toFixed(0),
min: 0,
max: Math.round({/literal}{$GLOBAL.workers}{literal} * 2),
title: "Miners",
gaugeColor: '#6f7a8a',
labelFontColor: '#555',
titleFontColor: '#555',
valueFontColor: '#555',
label: "Active Miners",
relativeGaugeSize: true,
showMinMax: true,
shadowOpacity : 0.8,
shadowSize : 0,
shadowVerticalOffset : 10
});
g2 = new JustGage({
id: "hr",
value: parseFloat({/literal}{$GLOBAL.hashrate}{literal}).toFixed(2),
min: 0,
max: Math.round({/literal}{$GLOBAL.hashrate}{literal} * 2),
title: "Pool Hashrate",
gaugeColor: '#6f7a8a',
labelFontColor: '#555',
titleFontColor: '#555',
valueFontColor: '#555',
label: "{/literal}{$GLOBAL.hashunits.pool}{literal}",
relativeGaugeSize: true,
showMinMax: true,
shadowOpacity : 0.8,
shadowSize : 0,
shadowVerticalOffset : 10
});
{/literal}{if $GLOBAL.config.disable_navbar|default:"0" != 1 && $GLOBAL.config.disable_navbar_api|default:"0" != 1}{literal}
// Helper to refresh graphs
function refreshInformation(data) {
g1.refresh(parseFloat(data.getnavbardata.data.pool.workers).toFixed(0));
g2.refresh(parseFloat(data.getnavbardata.data.pool.hashrate).toFixed(2));
if (storedWorkers.length > 20) { storedWorkers.shift(); }
if (storedHashrate.length > 20) { storedHashrate.shift(); }
timeNow = new Date().getTime();
storedWorkers[storedWorkers.length] = [timeNow, data.getnavbardata.data.raw.pool.workers];
storedHashrate[storedHashrate.length] = [timeNow, data.getnavbardata.data.raw.pool.hashrate];
}
// Our worker process to keep gauges and graph updated
(function worker() {
$.ajax({
url: url,
dataType: 'json',
success: function(data) {
refreshInformation(data);
},
complete: function() {
setTimeout(worker, {/literal}{($GLOBAL.config.statistics_ajax_refresh_interval * 1000)|default:"1000"}{literal})
}
});
{/literal}{/if}{literal}
})();
});
{/literal}
</script>