// ==UserScript==
// @id iitc-plugin-show-linked-portals@fstopienski
// @name IITC plugin: Show linked portals
// @category Portal Info
// @version 0.2.0.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Try to show the linked portals (image, name and link direction) in portal detail view and jump to linked portal on click. Some details may not be available if the linked portal is not in the current view.
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @grant none
// ==/UserScript==
@@PLUGINSTART@@
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.showLinkedPortal = function () {
};
window.plugin.showLinkedPortal.portalDetail = function (data) {
var portalLinks = getPortalLinks(data.guid);
var c = 1;
$.each(portalLinks.out, function(index,linkGuid) {
// outgoing links - so the other portal is the destination
var otherPortalGuid = window.links[linkGuid].options.data.dGuid;
var portalInfo = window.plugin.showLinkedPortal.getPortalByGuid(otherPortalGuid, true);
$('#portaldetails').append('
' + portalInfo + '
');
c = c + 1;
});
$.each(portalLinks.in, function(index,linkGuid) {
// incoming link - so the other portal is the origin
var otherPortalGuid = window.links[linkGuid].options.data.oGuid;
var portalInfo = window.plugin.showLinkedPortal.getPortalByGuid(otherPortalGuid, false);
$('#portaldetails').append('' + portalInfo + '
');
c = c + 1;
});
$('.showLinkedPortalLink:not(.outOfRange)').bind('click', function () {
var guid = $(this).attr('data-guid');
window.renderPortalDetails(guid);
var latlng = findPortalLatLng(guid);
if (latlng) {
if (!map.getBounds().pad(-0.1).contains(latlng)) {
map.panTo(latlng);
}
} else {
// no idea where this portal is(!) - so step back one zoom level
map.setZoom(map.getZoom()-1);
}
});
}
window.plugin.showLinkedPortal.getPortalByGuid = function (guid,isorigin) {
var linkDirection = $('').text(isorigin?'↴ outgoing link':'↳ incoming link');
var portalInfoString;
if (window.portals[guid] !== undefined) {
var portalData = window.portals[guid].options.data;
var portalNameAddressAlt = "'" + portalData.title + "'";
var portalNameAddressTitle = $('').append($('').text(portalData.title))
.append($('
'))
.append(linkDirection)
.html();
var imageUrl = fixPortalImageUrl(portalData.image);
portalInfoString = $('').html($('
').attr('src', imageUrl)
.attr('class', 'minImg')
.attr('alt', portalNameAddressAlt)
.attr('title', portalNameAddressTitle))
.html();
} else {
var title = $('').append($('').text('Go to portal'))
.append($('
'))
.append(linkDirection)
.html();
portalInfoString = $('').html($('').attr('class','outOfRange')
.attr('title',title)
.text('Portal out of range.'))
.html();
}
return portalInfoString;
};
var setup = function () {
window.addHook('portalDetailsUpdated', window.plugin.showLinkedPortal.portalDetail);
$('head').append('');
}
// PLUGIN END //////////////////////////////////////////////////////////
@@PLUGINEND@@