// ==UserScript==
// @id iitc-plugin-portals-count@yenky
// @name IITC plugin: Show total counts of portals
// @category Info
// @version 0.1.2.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Display a list of all localized portals by level and faction.
// @include https://*.ingress.com/intel*
// @include http://*.ingress.com/intel*
// @match https://*.ingress.com/intel*
// @match http://*.ingress.com/intel*
// @include https://*.ingress.com/mission/*
// @include http://*.ingress.com/mission/*
// @match https://*.ingress.com/mission/*
// @match http://*.ingress.com/mission/*
// @grant none
// ==/UserScript==
@@PLUGINSTART@@
// PLUGIN START ////////////////////////////////////////////////////////
/* whatsnew
* 0.1.0 : display graphs
* 0.0.10 : show in nav drawer on mobile devices
* 0.0.9 : fix for new intel map
* 0.0.8 : use dialog() instead of alert()
* 0.0.6 : ignoring outside bounds portals (even if close to)
* 0.0.5 : changed table layout, added some colors
* 0.0.4 : reverse show order of portals, using MAX_PORTAL_LEVEL now for array, changed table layout to be more compact, cleaned up code
* 0.0.3 : fixed incorrect rounded portal levels, adjusted viewport
* 0.0.2 : fixed counts to be reset after scrolling
* 0.0.1 : initial release, show count of portals
*/
// use own namespace for plugin
window.plugin.portalcounts = {
BAR_TOP: 20,
BAR_HEIGHT: 180,
BAR_WIDTH: 25,
BAR_PADDING: 5,
RADIUS_INNER: 70,
RADIUS_OUTER: 100,
CENTER_X: 200,
CENTER_Y: 100,
};
//count portals for each level available on the map
window.plugin.portalcounts.getPortals = function (){
//console.log('** getPortals');
var self = window.plugin.portalcounts;
var displayBounds = map.getBounds();
self.enlP = 0;
self.resP = 0;
self.neuP = 0;
self.PortalsEnl = new Array();
self.PortalsRes = new Array();
for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){
self.PortalsEnl[level] = 0;
self.PortalsRes[level] = 0;
}
$.each(window.portals, function(i, portal) {
var level = portal.options.level;
var team = portal.options.team;
// just count portals in viewport
if(!displayBounds.contains(portal.getLatLng())) return true;
switch (team){
case 1 :
self.resP++;
self.PortalsRes[level]++;
break;
case 2 :
self.enlP++;
self.PortalsEnl[level]++;
break;
default:
self.neuP++;
break;
}
});
//get portals informations from IITC
var minlvl = getMinPortalLevel();
var total = self.neuP + self.enlP + self.resP;
var counts = '';
if(total > 0) {
counts += '
| Enlightened | Resistance |
'; //'+self.enlP+' Portal(s)';
for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){
counts += 'Level '+level+' | ';
if(minlvl > level)
counts += 'zoom in to see portals in this level | ';
else
counts += ''+self.PortalsEnl[level]+' | '+self.PortalsRes[level]+' | ';
counts += '
';
}
counts += 'Total: | '+self.enlP+' | '+self.resP+' |
';
counts += 'Neutral: | ';
if(minlvl > 0)
counts += 'zoom in to see unclaimed portals';
else
counts += self.neuP;
counts += ' |
';
var svg = $('