// PORTAL DETAILS MAIN /////////////////////////////////////////////// // main code block that renders the portal details in the sidebar and // methods that highlight the portal in the map view. window.renderPortalDetails = function(guid) { var d = portalsDetail[guid]; if(!d) { unselectOldPortal(); urlPortal = guid; return; } var update = selectPortal(guid); // collect some random data that’s not worth to put in an own method var links = {incoming: 0, outgoing: 0}; if(d.portalV2.linkedEdges) $.each(d.portalV2.linkedEdges, function(ind, link) { links[link.isOrigin ? 'outgoing' : 'incoming']++; }); var linksText = 'links: ↳ ' + links.incoming+' • '+links.outgoing+' ↴'; var player = d.captured && d.captured.capturingPlayerId ? getPlayerName(d.captured.capturingPlayerId) : null; var playerText = player ? 'owner: ' + player : null; var time = d.captured ? unixTimeToString(d.captured.capturedTime) : null; var sinceText = time ? 'since: ' + time : null; // collect and html-ify random data var randDetails = [playerText, sinceText, getRangeText(d), getEnergyText(d), linksText, getAvgResoDistText(d)]; randDetails = randDetails.map(function(detail) { if(!detail) return ''; detail = detail.split(':'); detail = ''; return detail; }).join('\n'); // replacing causes flicker, so if the selected portal does not // change, only update the data points that are likely to change. if(update) { console.log('Updating portal details'); $('#level').text(Math.floor(getPortalLevel(d))); $('.mods').html(getModDetails(d)); $('#randdetails').html(randDetails); $('#resodetails').html(getResonatorDetails(d)); $('#portaldetails').attr('class', TEAM_TO_CSS[getTeam(d)]); } else { console.log('exchanging portal details'); setPortalIndicators(d); var img = d.imageByUrl && d.imageByUrl.imageUrl ? d.imageByUrl.imageUrl : DEFAULT_PORTAL_IMG; var lat = d.locationE6.latE6; var lng = d.locationE6.lngE6; var perma = 'http://ingress.com/intel?latE6='+lat+'&lngE6='+lng+'&z=17&pguid='+guid; $('#portaldetails') .attr('class', TEAM_TO_CSS[getTeam(d)]) .html('' + '