<commit_before>// ==UserScript==
// @id             iitc-plugin-portals-count@yenky
// @name           IITC plugin: Show total counts of portals
// @version        0.0.5.@@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*
// ==/UserScript==

/* whatsnew
* 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
* todo : 
*/ 

function wrapper() {
// ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function') window.plugin = function() {};

// PLUGIN START ////////////////////////////////////////////////////////

// use own namespace for plugin
window.plugin.portalcounts = function() {};
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;
    
  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 :<commit_msg>Ignoring out of bounds portals by current bounds (better than manipulating default value)<commit_after>// ==UserScript==
// @id             iitc-plugin-portals-count@yenky
// @name           IITC plugin: Show total counts of portals
// @version        0.0.6.@@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*
// ==/UserScript==

/* whatsnew
* 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
* todo : 
*/ 

function wrapper() {
// ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function') window.plugin = function() {};

// PLUGIN START ////////////////////////////////////////////////////////

// use own namespace for plugin
window.plugin.portalcounts = function() {};

//count portals for each level avalaible 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 d = portal.options.details;
    var team = portal.options.team;
    var level = Math.floor(getPortalLevel(d));
    // just count portals in viewport
    if(!displayBounds.contains(portal.getLatLng())) return true;
    switch (team){
      case 1 :
{'fraction_non_alphanumeric': 0.1540436456996149, 'fraction_numerical': 0.012195121951219513, 'mean_word_length': 2.955160744500846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5975881', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1459, 'n_words': 395}