')
.attr({class:'imgpreview', title:imgTitle, style:"background-image: url('"+img+"')"})
.append(
$('
').attr({id:'level', title: levelDetails}).text(levelInt),
$('
').attr({class:'hide', src:img})
),
modDetails,
miscDetails,
resoDetails,
statusDetails,
'' + linkDetails.join('') + '
'
);
// only run the hooks when we have a portalDetails object - most plugins rely on the extended data
// TODO? another hook to call always, for any plugins that can work with less data?
if (details) {
runHooks('portalDetailsUpdated', {guid: guid, portal: portal, portalDetails: details, portalData: data});
}
}
window.getPortalMiscDetails = function(guid,d) {
var randDetails;
if (d) {
// collect some random data that’s not worth to put in an own method
var linkInfo = getPortalLinks(guid);
var maxOutgoing = getMaxOutgoingLinks(d);
var linkCount = linkInfo.in.length + linkInfo.out.length;
var links = {incoming: linkInfo.in.length, outgoing: linkInfo.out.length};
var title = 'at most ' + maxOutgoing + ' outgoing links\n' +
links.outgoing + ' links out\n' +
links.incoming + ' links in\n' +
'(' + (links.outgoing+links.incoming) + ' total)'
var linksText = ['links', links.outgoing+' out / '+links.incoming+' in', title];
var player = d.owner
? '' + d.owner + ''
: '-';
var playerText = ['owner', player];
var fieldCount = getPortalFieldsCount(guid);
var fieldsText = ['fields', fieldCount];
var apGainText = getAttackApGainText(d,fieldCount,linkCount);
var attackValues = getPortalAttackValues(d);
// collect and html-ify random data
var randDetailsData = [
// these pieces of data are only relevant when the portal is captured
// maybe check if portal is captured and remove?
// But this makes the info panel look rather empty for unclaimed portals
playerText, getRangeText(d),
linksText, fieldsText,
getMitigationText(d,linkCount), getEnergyText(d),
// and these have some use, even for uncaptured portals
apGainText, getHackDetailsText(d),
];
if(attackValues.attack_frequency != 0)
randDetailsData.push([
'attack frequency',
'×'+attackValues.attack_frequency]);
if(attackValues.hit_bonus != 0)
randDetailsData.push(['hit bonus', attackValues.hit_bonus+'%']);
if(attackValues.force_amplifier != 0)
randDetailsData.push([
'force amplifier',
'×'+attackValues.force_amplifier]);
randDetails = '' + genFourColumnTable(randDetailsData) + '
';
// artifacts - tacked on after (but not as part of) the 'randdetails' table
// instead of using the existing columns....
if (d.artifactBrief && d.artifactBrief.target && Object.keys(d.artifactBrief.target).length > 0) {
var targets = Object.keys(d.artifactBrief.target);
//currently (2015-07-10) we no longer know the team each target portal is for - so we'll just show the artifact type(s)
randDetails += 'Target portal: '+targets.map(function(x) { return x.capitalize(); }).join(', ')+'
';
}
// shards - taken directly from the portal details
if (d.artifactDetail) {
randDetails += 'Shards: '+d.artifactDetail.displayName+' #'+d.artifactDetail.fragments.join(', ')+'
';
}
}
return randDetails;
}
// draws link-range and hack-range circles around the portal with the
// given details. Clear them if parameter 'd' is null.
window.setPortalIndicators = function(p) {
if(portalRangeIndicator) map.removeLayer(portalRangeIndicator);
portalRangeIndicator = null;
if(portalAccessIndicator) map.removeLayer(portalAccessIndicator);
portalAccessIndicator = null;
// if we have a portal...
if(p) {
var coord = p.getLatLng();
// range is only known for sure if we have portal details
// TODO? render a min range guess until details are loaded..?
var d = portalDetail.get(p.options.guid);
if (d) {
var range = getPortalRange(d);
portalRangeIndicator = (range.range > 0
? L.geodesicCircle(coord, range.range, {
fill: false,
color: RANGE_INDICATOR_COLOR,
weight: 3,
dashArray: range.isLinkable ? undefined : "10,10",
clickable: false })
: L.circle(coord, range.range, { fill: false, stroke: false, clickable: false })
).addTo(map);
}
portalAccessIndicator = L.circle(coord, HACK_RANGE,
{ fill: false, color: ACCESS_INDICATOR_COLOR, weight: 2, clickable: false }
).addTo(map);
}
}
// highlights portal with given GUID. Automatically clears highlights
// on old selection. Returns false if the selected portal changed.
// Returns true if it's still the same portal that just needs an
// update.
window.selectPortal = function(guid) {
var update = selectedPortal === guid;
var oldPortalGuid = selectedPortal;
selectedPortal = guid;
var oldPortal = portals[oldPortalGuid];
var newPortal = portals[guid];
// Restore style of unselected portal
if(!update && oldPortal) setMarkerStyle(oldPortal,false);
// Change style of selected portal
if(newPortal) {
setMarkerStyle(newPortal, true);
if (map.hasLayer(newPortal)) {
newPortal.bringToFront();
}
}
setPortalIndicators(newPortal);
runHooks('portalSelected', {selectedPortalGuid: guid, unselectedPortalGuid: oldPortalGuid});
return update;
}