allow portal highlighters for placeholder portals - several (e.g. uniques) work just fine

fix several other highlighters to check for required data on portals
This commit is contained in:
Jon Atkins 2015-06-28 21:49:02 +01:00
parent bf795e7520
commit 8f1759d7c3
6 changed files with 20 additions and 18 deletions

View File

@ -30,12 +30,9 @@ window.setMarkerStyle = function(marker, selected) {
marker.setStyle(styleOptions); marker.setStyle(styleOptions);
// don't run highlighters if we only have placeholder data // FIXME? it's inefficient to set the marker style (above), then do it again inside the highlighter
if (marker.options.data.level !== undefined) { // the highlighter API would need to be changed for this to be improved though. will it be too slow?
// FIXME? it's inefficient to set the marker style (above), then do it again inside the highlighter highlightPortal(marker);
// the highlighter API would need to be changed for this to be improved though. will it be too slow?
highlightPortal(marker);
}
if (selected) { if (selected) {
marker.setStyle ({color: COLOR_SELECTED_PORTAL}); marker.setStyle ({color: COLOR_SELECTED_PORTAL});

View File

@ -27,19 +27,22 @@ window.plugin.portalHighlighterInactive = function() {};
window.plugin.portalHighlighterInactive.highlight = function(data) { window.plugin.portalHighlighterInactive.highlight = function(data) {
var daysUnmodified = (new Date().getTime() - data.portal.options.timestamp) / (24*60*60*1000); if (data.portal.options.timestamp > 0) {
if (daysUnmodified >= 7) { var daysUnmodified = (new Date().getTime() - data.portal.options.timestamp) / (24*60*60*1000);
var fill_opacity = Math.min(1,((daysUnmodified-7)/24)*.85 + .15); if (daysUnmodified >= 7) {
var blue = Math.max(0,Math.min(255,Math.round((daysUnmodified-31)/62*255))); var fill_opacity = Math.min(1,((daysUnmodified-7)/24)*.85 + .15);
var colour = 'rgb(255,0,'+blue+')'; var blue = Math.max(0,Math.min(255,Math.round((daysUnmodified-31)/62*255)));
var params = {fillColor: colour, fillOpacity: fill_opacity}; var colour = 'rgb(255,0,'+blue+')';
data.portal.setStyle(params); var params = {fillColor: colour, fillOpacity: fill_opacity};
data.portal.setStyle(params);
}
} }
} }

View File

@ -27,8 +27,10 @@ window.plugin.portalHighlighterPortalsLevelColor = function() {};
window.plugin.portalHighlighterPortalsLevelColor.colorLevel = function(data) { window.plugin.portalHighlighterPortalsLevelColor.colorLevel = function(data) {
var portal_level = data.portal.options.data.level; var portal_level = data.portal.options.data.level;
var opacity = .6; if (portal_level !== undefined) {
data.portal.setStyle({fillColor: COLORS_LVL[portal_level], fillOpacity: opacity}); var opacity = .6;
data.portal.setStyle({fillColor: COLORS_LVL[portal_level], fillOpacity: opacity});
}
} }
var setup = function() { var setup = function() {

View File

@ -30,7 +30,7 @@ window.plugin.portalsMissingResonators.highlight = function(data) {
if(data.portal.options.team != TEAM_NONE) { if(data.portal.options.team != TEAM_NONE) {
var res_count = data.portal.options.data.resCount; var res_count = data.portal.options.data.resCount;
if(res_count < 8) { if(res_count !== undefined && res_count < 8) {
var fill_opacity = ((8-res_count)/8)*.85 + .15; var fill_opacity = ((8-res_count)/8)*.85 + .15;
var color = 'red'; var color = 'red';
var params = {fillColor: color, fillOpacity: fill_opacity}; var params = {fillColor: color, fillOpacity: fill_opacity};

View File

@ -29,7 +29,7 @@ window.plugin.portalHighlighterNeedsRecharge.highlight = function(data) {
var d = data.portal.options.data; var d = data.portal.options.data;
var health = d.health; var health = d.health;
if(data.portal.options.team != TEAM_NONE && health < 100) { if(health !== undefined && data.portal.options.team != TEAM_NONE && health < 100) {
var color,fill_opacity; var color,fill_opacity;
if (health > 95) { if (health > 95) {
color = 'yellow'; color = 'yellow';

View File

@ -27,7 +27,7 @@ window.plugin.portalWeakness = function() {};
window.plugin.portalWeakness.highlightWeakness = function(data) { window.plugin.portalWeakness.highlightWeakness = function(data) {
if(data.portal.options.team != TEAM_NONE) { if(data.portal.options.resCount !== undefined && data.portal.options.data.health !== undefined && data.portal.options.team != TEAM_NONE) {
var res_count = data.portal.options.data.resCount; var res_count = data.portal.options.data.resCount;
var portal_health = data.portal.options.data.health; var portal_health = data.portal.options.data.health;