Merge branch 'framed_ap_stats_plugin' of git://github.com/framed/ingress-intel-total-conversion into framed-framed_ap_stats_plugin
This commit is contained in:
commit
baaf098977
@ -21,7 +21,25 @@ if(typeof window.plugin !== 'function') window.plugin = function() {};
|
||||
window.plugin.compAPStats = function() {};
|
||||
|
||||
window.plugin.compAPStats.setupCallback = function() {
|
||||
$('#toolbox').append('<a onclick="window.plugin.compAPStats.guess()">Compute AP Stats</a> ');
|
||||
// add a new div to the bottom of the sidebar and style it
|
||||
$('#sidebar').append('<div id="available_ap_display"></div>');
|
||||
$('#available_ap_display').css({'color':'#ffce00', 'font-size':'90%', 'padding':'4px 2px'});
|
||||
|
||||
// do an initial calc for sidebar sizing purposes
|
||||
window.plugin.compAPStats.onPositionMove();
|
||||
|
||||
// make the value update when the map data updates
|
||||
var handleDataResponseOrig = window.handleDataResponse;
|
||||
window.handleDataResponse = function(data, textStatus, jqXHR) {
|
||||
handleDataResponseOrig(data, textStatus, jqXHR);
|
||||
window.plugin.compAPStats.onPositionMove();
|
||||
}
|
||||
}
|
||||
|
||||
window.plugin.compAPStats.onPositionMove = function() {
|
||||
var result = window.plugin.compAPStats.compAPStats();
|
||||
$('#available_ap_display').html("Available AP in this area:<br/> Enlightened:\t" +
|
||||
digits(result[1]) + "<br/> Resistance:\t" + digits(result[0]));
|
||||
}
|
||||
|
||||
window.plugin.compAPStats.compAPStats = function() {
|
||||
@ -34,11 +52,15 @@ window.plugin.compAPStats.compAPStats = function() {
|
||||
var allEnlEdges = [];
|
||||
var allEnlFields = [];
|
||||
|
||||
var displayBounds = map.getBounds();
|
||||
|
||||
// Grab every portal in the viewable area and compute individual AP stats
|
||||
$.each(window.portals, function(ind, portal) {
|
||||
var d = portal.options.details;
|
||||
|
||||
// eliminate offscreen portals (selected, and in padding)
|
||||
if(!displayBounds.contains(portal.getLatLng())) return true;
|
||||
|
||||
var portalStats = getAttackApGain(d);
|
||||
var portalSum = portalStats.resoAp + portalStats.captureAp;
|
||||
|
||||
@ -89,18 +111,6 @@ window.plugin.compAPStats.compAPStats = function() {
|
||||
return [totalAP_RES, totalAP_ENL];
|
||||
}
|
||||
|
||||
window.plugin.compAPStats.guess = function() {
|
||||
var res = window.plugin.compAPStats.compAPStats();
|
||||
var totalAP_RES = res[0];
|
||||
var totalAP_ENL = res[1];
|
||||
|
||||
var s = 'Calculated AP gain potential:\n\n';
|
||||
s += 'Available Resistance AP:\t' + digits(totalAP_RES) + '\n';
|
||||
s += 'Available Enlightened AP:\t' + digits(totalAP_ENL) + '\n';
|
||||
|
||||
alert(s);
|
||||
}
|
||||
|
||||
var setup = function() {
|
||||
window.plugin.compAPStats.setupCallback();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user