diff --git a/plugins/portal-counts.user.js b/plugins/portal-counts.user.js
index fc43c048..388bc125 100644
--- a/plugins/portal-counts.user.js
+++ b/plugins/portal-counts.user.js
@@ -1,7 +1,7 @@
// ==UserScript==
// @id iitc-plugin-portals-count@yenky
// @name IITC plugin: Show total counts of portals
-// @version 0.0.3.@@DATETIMEVERSION@@
+// @version 0.0.4.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@@ -27,99 +27,78 @@ if(typeof window.plugin !== 'function') window.plugin = function() {};
// use own namespace for plugin
window.plugin.portalcounts = function() {};
- window.VIEWPORT_PAD_RATIO = 0.1;
+window.VIEWPORT_PAD_RATIO = 0.1;
//count portals for each level avalaible on the map
window.plugin.portalcounts.getPortals = function(){
- //console.log('** getPortals');
- // just count portals in viewport, default: 0.3
- var retval=false;
- window.plugin.portalcounts.enlP = 0;
- window.plugin.portalcounts.resP = 0;
- window.plugin.portalcounts.neuP = 0;
+ //console.log('** getPortals');
+ // just count portals in viewport, default: 0.3
+ var retval=false;
+ window.plugin.portalcounts.enlP = 0;
+ window.plugin.portalcounts.resP = 0;
+ window.plugin.portalcounts.neuP = 0;
- window.plugin.portalcounts.PortalsEnl = new Array();
- window.plugin.portalcounts.PortalsEnl[1] = 0;
- window.plugin.portalcounts.PortalsEnl[2] = 0;
- window.plugin.portalcounts.PortalsEnl[3] = 0;
- window.plugin.portalcounts.PortalsEnl[4] = 0;
- window.plugin.portalcounts.PortalsEnl[5] = 0;
- window.plugin.portalcounts.PortalsEnl[6] = 0;
- window.plugin.portalcounts.PortalsEnl[7] = 0;
- window.plugin.portalcounts.PortalsEnl[8] = 0;
- window.plugin.portalcounts.PortalsRes= new Array();
- window.plugin.portalcounts.PortalsRes[1] = 0;
- window.plugin.portalcounts.PortalsRes[2] = 0;
- window.plugin.portalcounts.PortalsRes[3] = 0;
- window.plugin.portalcounts.PortalsRes[4] = 0;
- window.plugin.portalcounts.PortalsRes[5] = 0;
- window.plugin.portalcounts.PortalsRes[6] = 0;
- window.plugin.portalcounts.PortalsRes[7] = 0;
- window.plugin.portalcounts.PortalsRes[8] = 0;
- //get portals informations from IITC
- var minlvl = getMinPortalLevel();
+ 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 d = portal.options.details;
- var team = portal.options.team;
- var level = Math.floor(getPortalLevel(d));
- 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;
- }
-
- });
- var counts = '
';
- if(retval) {
- counts += 'Enlightment: '+window.plugin.portalcounts.enlP+' Portal(s) |
';
- for (level in window.plugin.portalcounts.PortalsEnl) {
- counts += 'Level '+level+' | ';
- if(minlvl > level)
- counts += 'zoom in';
- else
- counts += window.plugin.portalcounts.PortalsEnl[level];
- counts += ' |
';
- }
- counts += '  |
';
- counts += 'Resistance: '+window.plugin.portalcounts.resP+' Portal(s) |
';
- for (level in window.plugin.portalcounts.PortalsRes) {
- counts += 'Level '+level+' | '
- if(minlvl > level)
- counts += 'zoom in';
- else
- counts += window.plugin.portalcounts.PortalsRes[level];
- counts += ' |
';
- }
- counts += '  |
';
- counts += 'Neutral: ';
- if(minlvl > 0)
- counts += 'zoom in to see unclaimed';
- else
- counts += window.plugin.portalcounts.neuP;
- counts += ' Portal(s) |
';
- } else
- counts += 'No Portals in range ! |
';
- counts += '
';
- counts += 'Thanks to @teo96 for his plugin as base for me. Work done by
@yenky. Be enlightened!
';
- alert(''+counts+'
');
+ $.each(window.portals, function(i, portal) {
+ retval=true;
+ var d = portal.options.details;
+ var team = portal.options.team;
+ var level = Math.floor(getPortalLevel(d));
+ 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 += ' | Enlightment | Resistance |
'; //'+window.plugin.portalcounts.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 += ''+window.plugin.portalcounts.PortalsEnl[level]+' | '+window.plugin.portalcounts.PortalsRes[level]+' | ';
+ counts += '
';
+ }
+ counts += '  |
';
+ counts += 'Neutral: | ';
+ if(minlvl > 0)
+ counts += 'zoom in to see unclaimed';
+ else
+ counts += window.plugin.portalcounts.neuP;
+ counts += ' Portal(s) |
';
+ counts += 'Enlightment: | '+window.plugin.portalcounts.enlP+' Portal(s) |
';
+ counts += 'Resistance: | '+window.plugin.portalcounts.resP+' Portal(s) |
';
+ } else
+ counts += 'No Portals in range ! |
';
+ counts += '
';
+ alert(''+counts+'
');
}
var setup = function() {
$('body').append('');
$('#toolbox').append('Portalcounts');
$('head').append('');
}