Merge pull request #4 from Hollow011/gh-pages

Merge requested small style changes from base repo owner
This commit is contained in:
Hollow011 2013-02-19 23:21:46 -08:00
commit e04572a08c
3 changed files with 24 additions and 19 deletions

View File

@ -30,11 +30,16 @@
// yet been displayed. The data hash contains both the un-
// processed raw ajax response as well as the processed
// chat data that is going to be used for display.
// portalDataLoaded: callback is passed the argument of
// {portals : [portal, portal, ...]} where "portal" is the
// data element and not the leaflet object. "portal" is an
// array [GUID, time, details]. Plugin can manipulate the
// array to change order or add additional values to the
// details of a portal.
window._hooks = {}
window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated',
'publicChatDataAvailable'];
'publicChatDataAvailable', 'portalDataLoaded'];
window.runHooks = function(event, data) {
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);

View File

@ -127,6 +127,8 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
// Preserve and restore "selectedPortal" between portal re-render
if(portalUpdateAvailable) var oldSelectedPortal = selectedPortal;
runHooks('portalDataLoaded', {portals : ppp});
$.each(ppp, function(ind, portal) { renderPortal(portal); });
var selectedPortalLayer = portals[oldSelectedPortal];

View File

@ -1,10 +1,10 @@
// ==UserScript==
// @id iitc-plugin-compute-ap-stats@breunigs
// @id iitc-plugin-compute-ap-stats@Hollow011
// @name iitc: Compute AP statistics
// @version 0.1
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute_AP_stats.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute_AP_stats.user.js
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-AP-stats.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-AP-stats.user.js
// @description Tries to determine overal AP stats for the current zoom
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
@ -29,15 +29,15 @@ window.plugin.compAPStats.compAPStats = function() {
var totalAP_RES = 0;
var totalAP_ENL = 0;
var allResEdges = new Array();
var allResFields = new Array();
var allEnlEdges = new Array();
var allEnlFields = new Array();
var allResEdges = [];
var allResFields = [];
var allEnlEdges = [];
var allEnlFields = [];
// Grab every portal in the viewable area and compute individual AP stats (ignoring links and fields for now)
$.each(window.portals, function(ind, portal) {
var d = portal.options.details
var d = portal.options.details;
var resoCount = 0;
// see how many resonators the portal has
@ -50,7 +50,6 @@ window.plugin.compAPStats.compAPStats = function() {
var resoAp = resoCount * DESTROY_RESONATOR;
var portalSum = resoAp + CAPTURE_PORTAL + 8*DEPLOY_RESONATOR + COMPLETION_BONUS;
// Team1 is a Res portal, Team2 is a Enl portal
if (getTeam(d) === TEAM_ENL) {
totalAP_RES += portalSum;
@ -76,8 +75,7 @@ window.plugin.compAPStats.compAPStats = function() {
if(!field) return true;
allResFields.push(field);
});
}
else {
} else {
// it's a neutral portal, potential for both teams. by definition no fields or edges
totalAP_ENL += portalSum;
totalAP_RES += portalSum;