// ==UserScript==
// @id iitc-plugin-show-linked-portals@fstopienski
// @name IITC plugin: Show linked portals
// @category Portal Info
// @version 0.1.1.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Tries to show the linked portals (image, name and address) in portal detail view and jump to linked portal on click
// @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 ////////////////////////////////////////////////////////
/*
* 0.0.1 initial release, show images, names and addresses of linked portal in portal detailview
* - mouse click of the linked portal image selected the portal and adjust map
* - click of "Linked Portal is out of range" zoom a step out
*/
// use own namespace for plugin
window.plugin.showLinkedPortal = function () {
};
window.plugin.showLinkedPortal.handleUpdate = function () {
if (!requests.isLastRequest('getThinnedEntitiesV4')) {
return;
}
}
window.plugin.showLinkedPortal.portalDetail = function (data) {
// don't render linked portal data if portal is neutral.
// (the data can remain sometimes - when a portal decays?)
if (data.portalDetails.controllingTeam.team == 'NEUTRAL')
return;
var d = data.portalDetails.portalV2,
c = 1;
//get linked portals
$(d.linkedEdges).each(function () {
var portalInfo = window.plugin.showLinkedPortal.getPortalByGuid(this.otherPortalGuid, this.isOrigin);
$('#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;
};
window.plugin.showLinkedPortal.setupCallback = function () {
// make the value update when the map data updates
var handleDataResponseOrig = window.handleDataResponse;
window.handleDataResponse = function (data, textStatus, jqXHR) {
handleDataResponseOrig(data, textStatus, jqXHR);
window.renderPortalDetails(window.selectedPortal);
}
}
var setup = function () {
window.addHook('requestFinished', window.plugin.showLinkedPortal.handleUpdate);
window.addHook('portalDetailsUpdated', window.plugin.showLinkedPortal.portalDetail);
$('head').append('');
window.plugin.showLinkedPortal.setupCallback();
}
// PLUGIN END //////////////////////////////////////////////////////////
@@PLUGINEND@@