diff --git a/plugins/show-linked-portals.user.js b/plugins/show-linked-portals.user.js index d9669e67..fe573bf4 100644 --- a/plugins/show-linked-portals.user.js +++ b/plugins/show-linked-portals.user.js @@ -2,7 +2,7 @@ // @id iitc-plugin-show-linked-portals@fstopienski // @name IITC plugin: Show linked portals // @category Portal Info -// @version 0.0.8.@@DATETIMEVERSION@@ +// @version 0.1.0.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ @@ -44,7 +44,7 @@ window.plugin.showLinkedPortal.portalDetail = function (data) { c = 1; //get linked portals $(d.linkedEdges).each(function () { - var portalInfo = window.plugin.showLinkedPortal.getPortalByGuid(this.otherPortalGuid); + var portalInfo = window.plugin.showLinkedPortal.getPortalByGuid(this.otherPortalGuid, this.isOrigin); $('#portaldetails').append(''); c = c + 1; }); @@ -61,22 +61,27 @@ window.plugin.showLinkedPortal.portalDetail = function (data) { map.setView(Rlatlng, map.getZoom()); } else { + // TODO: instead of just zooming out one level, check the link data for the start+end coordinates, + // and fit the map view to the bounding box map.setZoom((map.getZoom() - 1)); } }); } -window.plugin.showLinkedPortal.getPortalByGuid = function (guid) { - var portalInfoString = 'Linked Portal out of range.'; +window.plugin.showLinkedPortal.getPortalByGuid = function (guid,isorigin) { + var linkDirection = $('').text(isorigin?'↴ outgoing link':'↳ incoming link'); + + var portalInfoString; + if (window.portals[guid] !== undefined) { var portalDetails = window.portals[guid].options.details; - portalInfoString = ''; + var portalNameAdressAlt = "'" + portalDetails.portalV2.descriptiveText.TITLE + "' (" + portalDetails.portalV2.descriptiveText.ADDRESS + ")"; - var portalNameAdressTitle = $('
').append('\'') - .append($('').text(portalDetails.portalV2.descriptiveText.TITLE)) - .append('\'') + var portalNameAdressTitle = $('
').append($('').text(portalDetails.portalV2.descriptiveText.TITLE)) .append($('
')) .append($('').text('(' + portalDetails.portalV2.descriptiveText.ADDRESS + ')')) + .append($('
')) + .append(linkDirection) .html(); var imageUrl = getPortalImageUrl(portalDetails); portalInfoString = $('
').html($('').attr('src', imageUrl) @@ -84,7 +89,18 @@ window.plugin.showLinkedPortal.getPortalByGuid = function (guid) { .attr('alt', portalNameAdressAlt) .attr('title', portalNameAdressTitle)) .html(); + } else { + var title = $('
').append($('').text('Zoom out')) + .append($('
')) + .append(linkDirection) + .html(); + + portalInfoString = $('
').html($('').attr('class','outOfRange') + .attr('title',title) + .text('Portal out of range.')) + .html(); } + return portalInfoString; }; @@ -102,8 +118,8 @@ var setup = function () { window.addHook('portalDetailsUpdated', window.plugin.showLinkedPortal.portalDetail); $('head').append('