fix comparing of PLAYER.team with team in portal data (#929)
also, fix portals-list plugin from defaulting to the wrong sort column when bookmnarks plugin is active, and changed default sort order to decending for several columns
This commit is contained in:
		@@ -237,7 +237,7 @@ window.getAttackApGainText = function(d,fieldCount,linkCount) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  function tt(text) {
 | 
					  function tt(text) {
 | 
				
			||||||
    var t = '';
 | 
					    var t = '';
 | 
				
			||||||
    if (PLAYER.team == d.team) {
 | 
					    if (teamStringToId(PLAYER.team) == teamStringToId(d.team)) {
 | 
				
			||||||
      totalGain = breakdown.friendlyAp;
 | 
					      totalGain = breakdown.friendlyAp;
 | 
				
			||||||
      t += 'Friendly AP:\t' + breakdown.friendlyAp + '\n';
 | 
					      t += 'Friendly AP:\t' + breakdown.friendlyAp + '\n';
 | 
				
			||||||
      t += '  Deploy ' + breakdown.deployCount + ', ';
 | 
					      t += '  Deploy ' + breakdown.deployCount + ', ';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
// @id             iitc-plugin-portals-list@teo96
 | 
					// @id             iitc-plugin-portals-list@teo96
 | 
				
			||||||
// @name           IITC plugin: show list of portals
 | 
					// @name           IITC plugin: show list of portals
 | 
				
			||||||
// @category       Info
 | 
					// @category       Info
 | 
				
			||||||
// @version        0.2.0.@@DATETIMEVERSION@@
 | 
					// @version        0.2.1.@@DATETIMEVERSION@@
 | 
				
			||||||
// @namespace      https://github.com/jonatkins/ingress-intel-total-conversion
 | 
					// @namespace      https://github.com/jonatkins/ingress-intel-total-conversion
 | 
				
			||||||
// @updateURL      @@UPDATEURL@@
 | 
					// @updateURL      @@UPDATEURL@@
 | 
				
			||||||
// @downloadURL    @@DOWNLOADURL@@
 | 
					// @downloadURL    @@DOWNLOADURL@@
 | 
				
			||||||
@@ -84,7 +84,8 @@ window.plugin.portalslist.fields = [
 | 
				
			|||||||
      $(cell)
 | 
					      $(cell)
 | 
				
			||||||
        .addClass("alignR")
 | 
					        .addClass("alignR")
 | 
				
			||||||
        .text(portal.options.team===TEAM_NONE ? '-' : value+'%');
 | 
					        .text(portal.options.team===TEAM_NONE ? '-' : value+'%');
 | 
				
			||||||
    }
 | 
					    },
 | 
				
			||||||
 | 
					    defaultOrder: -1,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    title: "Res",
 | 
					    title: "Res",
 | 
				
			||||||
@@ -93,7 +94,8 @@ window.plugin.portalslist.fields = [
 | 
				
			|||||||
      $(cell)
 | 
					      $(cell)
 | 
				
			||||||
        .addClass("alignR")
 | 
					        .addClass("alignR")
 | 
				
			||||||
        .text(value);
 | 
					        .text(value);
 | 
				
			||||||
    }
 | 
					    },
 | 
				
			||||||
 | 
					    defaultOrder: -1,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    title: "Links",
 | 
					    title: "Links",
 | 
				
			||||||
@@ -105,7 +107,8 @@ window.plugin.portalslist.fields = [
 | 
				
			|||||||
        .addClass('help')
 | 
					        .addClass('help')
 | 
				
			||||||
        .attr('title', 'In:\t' + value.in.length + '\nOut:\t' + value.out.length)
 | 
					        .attr('title', 'In:\t' + value.in.length + '\nOut:\t' + value.out.length)
 | 
				
			||||||
        .text(value.in.length+value.out.length);
 | 
					        .text(value.in.length+value.out.length);
 | 
				
			||||||
    }
 | 
					    },
 | 
				
			||||||
 | 
					    defaultOrder: -1,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    title: "Fields",
 | 
					    title: "Fields",
 | 
				
			||||||
@@ -114,7 +117,8 @@ window.plugin.portalslist.fields = [
 | 
				
			|||||||
      $(cell)
 | 
					      $(cell)
 | 
				
			||||||
        .addClass("alignR")
 | 
					        .addClass("alignR")
 | 
				
			||||||
        .text(value);
 | 
					        .text(value);
 | 
				
			||||||
    }
 | 
					    },
 | 
				
			||||||
 | 
					    defaultOrder: -1,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    title: "AP",
 | 
					    title: "AP",
 | 
				
			||||||
@@ -126,7 +130,7 @@ window.plugin.portalslist.fields = [
 | 
				
			|||||||
    sortValue: function(value, portal) { return value.enemyAp; },
 | 
					    sortValue: function(value, portal) { return value.enemyAp; },
 | 
				
			||||||
    format: function(cell, portal, value) {
 | 
					    format: function(cell, portal, value) {
 | 
				
			||||||
      var title = '';
 | 
					      var title = '';
 | 
				
			||||||
      if (PLAYER.team == portal.options.data.team) {
 | 
					      if (teamStringToId(PLAYER.team) == portal.options.team) {
 | 
				
			||||||
        title += 'Friendly AP:\t'+value.friendlyAp+'\n'
 | 
					        title += 'Friendly AP:\t'+value.friendlyAp+'\n'
 | 
				
			||||||
               + '- deploy '+(8-portal.options.data.resCount)+' resonator(s)\n'
 | 
					               + '- deploy '+(8-portal.options.data.resCount)+' resonator(s)\n'
 | 
				
			||||||
               + '- upgrades/mods unknown\n';
 | 
					               + '- upgrades/mods unknown\n';
 | 
				
			||||||
@@ -140,7 +144,8 @@ window.plugin.portalslist.fields = [
 | 
				
			|||||||
        .addClass('help')
 | 
					        .addClass('help')
 | 
				
			||||||
        .prop('title', title)
 | 
					        .prop('title', title)
 | 
				
			||||||
        .html(digits(value.enemyAp));
 | 
					        .html(digits(value.enemyAp));
 | 
				
			||||||
    }
 | 
					    },
 | 
				
			||||||
 | 
					    defaultOrder: -1,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -202,7 +207,8 @@ window.plugin.portalslist.getPortals = function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
window.plugin.portalslist.displayPL = function() {
 | 
					window.plugin.portalslist.displayPL = function() {
 | 
				
			||||||
  var list;
 | 
					  var list;
 | 
				
			||||||
  window.plugin.portalslist.sortBy = 1;
 | 
					  // plugins (e.g. bookmarks) can insert fields before the standard ones - so we need to search for the 'level' column
 | 
				
			||||||
 | 
					  window.plugin.portalslist.sortBy = window.plugin.portalslist.fields.map(function(f){return f.title;}).indexOf('Level');
 | 
				
			||||||
  window.plugin.portalslist.sortOrder = -1;
 | 
					  window.plugin.portalslist.sortOrder = -1;
 | 
				
			||||||
  window.plugin.portalslist.enlP = 0;
 | 
					  window.plugin.portalslist.enlP = 0;
 | 
				
			||||||
  window.plugin.portalslist.resP = 0;
 | 
					  window.plugin.portalslist.resP = 0;
 | 
				
			||||||
@@ -245,6 +251,9 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) {
 | 
				
			|||||||
      return sortOrder * sortField.sort(valueA, valueB, a.portal, b.portal);
 | 
					      return sortOrder * sortField.sort(valueA, valueB, a.portal, b.portal);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//FIXME: sort isn't stable, so re-sorting identical values can change the order of the list.
 | 
				
			||||||
 | 
					//fall back to something constant (e.g. portal name?, portal GUID?),
 | 
				
			||||||
 | 
					//or switch to a stable sort so order of equal items doesn't change
 | 
				
			||||||
    return sortOrder *
 | 
					    return sortOrder *
 | 
				
			||||||
      (valueA < valueB ? -1 :
 | 
					      (valueA < valueB ? -1 :
 | 
				
			||||||
      valueA > valueB ?  1 :
 | 
					      valueA > valueB ?  1 :
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user