Display current energy for whole portal

This commit is contained in:
Pavol Babincak 2013-02-09 17:30:32 +01:00
parent c9045aa988
commit 904be9b5b1
4 changed files with 26 additions and 3 deletions

View File

@ -82,6 +82,7 @@ Contributors
[OshiHidra](https://github.com/OshiHidra),
[Xelio](https://github.com/Xelio),
[ZauberNerd](https://github.com/ZauberNerd)
[Scrool](https://github.com/Scrool)
Hacking

View File

@ -65,8 +65,12 @@ window.getModDetails = function(d) {
}
window.getEnergyText = function(d) {
var nrg = getPortalEnergy(d);
return 'energy: ' + (nrg > 1000 ? Math.round(nrg/1000) +'k': nrg);
var currentNrg = getCurrentPortalEnergy(d);
var totalNrg = getTotalPortalEnergy(d);
var inf = currentNrg + ' / ' + totalNrg;
var fill = prettyEnergy(currentNrg) + ' / ' + prettyEnergy(totalNrg)
var meter = 'energy: <tt title="'+inf+'">' + fill + '</tt>';
return meter;
}
window.getAvgResoDistText = function(d) {

View File

@ -17,7 +17,21 @@ window.getPortalLevel = function(d) {
return hasReso ? Math.max(1, lvl/8) : 0;
}
window.getPortalEnergy = function(d) {
window.getTotalPortalEnergy = function(d) {
var nrg = 0;
$.each(d.resonatorArray.resonators, function(ind, reso) {
if(!reso) return true;
var level = parseInt(reso.level);
var max = RESO_NRG[level];
nrg += max;
});
return nrg;
}
// For backwards compatibility
window.getPortalEnergy = window.getTotalPortalEnergy;
window.getCurrentPortalEnergy = function(d) {
var nrg = 0;
$.each(d.resonatorArray.resonators, function(ind, reso) {
if(!reso) return true;

View File

@ -148,3 +148,7 @@ if (typeof String.prototype.startsWith !== 'function') {
return this.slice(0, str.length) === str;
};
}
window.prettyEnergy = function(nrg) {
return nrg> 1000 ? Math.round(nrg/1000) + 'k': nrg;
}