// ==UserScript== // @id iitc-plugin-portals-count@yenky // @name IITC plugin: Show total counts of portals // @category Info // @version 0.0.10.@@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://www.ingress.com/intel* // @include http://www.ingress.com/intel* // @match https://www.ingress.com/intel* // @match http://www.ingress.com/intel* // @grant none // ==/UserScript== @@PLUGINSTART@@ // PLUGIN START //////////////////////////////////////////////////////// /* whatsnew * 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 = function() {}; //count portals for each level available on the map window.plugin.portalcounts.getPortals = function(){ //console.log('** getPortals'); var retval=false; var displayBounds = map.getBounds(); window.plugin.portalcounts.enlP = 0; window.plugin.portalcounts.resP = 0; window.plugin.portalcounts.neuP = 0; window.plugin.portalcounts.PortalsEnl = new Array(); window.plugin.portalcounts.PortalsRes = new Array(); for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){ window.plugin.portalcounts.PortalsEnl[level] = 0; window.plugin.portalcounts.PortalsRes[level] = 0; } $.each(window.portals, function(i, portal) { retval=true; 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 : window.plugin.portalcounts.resP++; window.plugin.portalcounts.PortalsRes[level]++; break; case 2 : window.plugin.portalcounts.enlP++; window.plugin.portalcounts.PortalsEnl[level]++; break; default: window.plugin.portalcounts.neuP++; break; } }); //get portals informations from IITC var minlvl = getMinPortalLevel(); var counts = ''; if(retval) { counts += ''; //'+window.plugin.portalcounts.enlP+' Portal(s)'; for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){ counts += ''; if(minlvl > level) counts += ''; else counts += ''; counts += ''; } counts += ''; counts += ''; } else counts += ''; counts += '
EnlightenedResistance
Level '+level+'zoom in to see portals in this level'+window.plugin.portalcounts.PortalsEnl[level]+''+window.plugin.portalcounts.PortalsRes[level]+'
Total:'+window.plugin.portalcounts.enlP+''+window.plugin.portalcounts.resP+'
Neutral:'; if(minlvl > 0) counts += 'zoom in to see unclaimed portals'; else counts += window.plugin.portalcounts.neuP; counts += '
No Portals in range!
'; var total = window.plugin.portalcounts.enlP + window.plugin.portalcounts.resP + window.plugin.portalcounts.neuP; var title = total + ' ' + (total == 1 ? 'portal' : 'portals'); if(typeof android !== 'undefined' && android && android.addPane) { $('
' + '
' + title + '
' + counts + '
').appendTo(document.body); } else { dialog({ html: '
' + counts + '
', title: 'Portal counts: ' + title, }); } } window.plugin.portalcounts.onPaneChanged = function(pane) { if(pane == "plugin-portalcounts") window.plugin.portalcounts.getPortals(); else $("#portalcounts").remove() }; var setup = function() { if(typeof android !== 'undefined' && android && android.addPane) { android.addPane("plugin-portalcounts", "Portal counts", "ic_action_data_usage"); addHook("paneChanged", window.plugin.portalcounts.onPaneChanged); } else { $('#toolbox').append(' Portal counts'); } $('head').append(''); } // PLUGIN END ////////////////////////////////////////////////////////// @@PLUGINEND@@