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);
// don't run highlighters if we only have placeholder data
if (marker.options.data.level !== undefined) {
// FIXME? it's inefficient to set the marker style (above), then do it again inside the highlighter
// the highlighter API would need to be changed for this to be improved though. will it be too slow?
highlightPortal(marker);
}
if (selected) {
marker.setStyle ({color: COLOR_SELECTED_PORTAL});

View File

@ -27,6 +27,8 @@ window.plugin.portalHighlighterInactive = function() {};
window.plugin.portalHighlighterInactive.highlight = function(data) {
if (data.portal.options.timestamp > 0) {
var daysUnmodified = (new Date().getTime() - data.portal.options.timestamp) / (24*60*60*1000);
if (daysUnmodified >= 7) {
@ -41,6 +43,7 @@ window.plugin.portalHighlighterInactive.highlight = function(data) {
data.portal.setStyle(params);
}
}
}

View File

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

View File

@ -30,7 +30,7 @@ window.plugin.portalsMissingResonators.highlight = function(data) {
if(data.portal.options.team != TEAM_NONE) {
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 color = 'red';
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 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;
if (health > 95) {
color = 'yellow';

View File

@ -27,7 +27,7 @@ window.plugin.portalWeakness = function() {};
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 portal_health = data.portal.options.data.health;