don't try and display an address when none is available

fix #454
This commit is contained in:
Jon Atkins 2013-07-28 18:39:12 +01:00
parent 02cb4fbe8f
commit 4caea29fd3
2 changed files with 10 additions and 4 deletions

View File

@ -17,7 +17,9 @@ window.getRangeText = function(d) {
window.getPortalDescriptionFromDetails = function(details) {
var descObj = details.portalV2.descriptiveText;
// FIXME: also get real description?
var desc = descObj.TITLE + '\n' + descObj.ADDRESS;
var desc = descObj.TITLE;
if(descObj.ADDRESS)
desc += '\n' + descObj.ADDRESS;
if(descObj.ATTRIBUTION)
desc += '\nby '+descObj.ATTRIBUTION+' ('+descObj.ATTRIBUTION_LINK+')';
return desc;

View File

@ -2,7 +2,7 @@
// @id iitc-plugin-show-address@vita10gy
// @name IITC plugin: show portal address in sidebar
// @category Portal Info
// @version 0.2.2.@@DATETIMEVERSION@@
// @version 0.2.3.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -26,10 +26,14 @@ window.plugin.portalAddress.portalDetail = function(data) {
// country, so get rid of it. If the country is in the [2] then it
// doesn't matter because address is usually short enough to fit.
var d = data.portalDetails.portalV2;
var address = d.descriptiveText.ADDRESS.split(',').splice(0,3).join(',');
var address = d.descriptiveText.ADDRESS;
if (address) {
address = address.split(',').splice(0,3).join(',');
$('.imgpreview').append('<div id="address">'+address+'</div>');
}
}
var setup = function() {
window.addHook('portalDetailsUpdated', window.plugin.portalAddress.portalDetail);
$('head').append('<style>' +