Display current energy for whole portal
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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) { | ||||
|   | ||||
| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user