X-Git-Url: https://git.openstreetmap.org/nominatim-ui.git/blobdiff_plain/710a464a6ac3e6b91980928992503a7d763ac820..1df5c38175a3d15f8e595f49506b4dfb46e73d29:/src/handlebar_helpers.js?ds=sidebyside diff --git a/src/handlebar_helpers.js b/src/handlebar_helpers.js index 358ac36..e233eb9 100644 --- a/src/handlebar_helpers.js +++ b/src/handlebar_helpers.js @@ -1,3 +1,5 @@ +'use strict'; + function formatOSMType(sType, bExcludeExternal) { if (sType === 'N') return 'node'; if (sType === 'W') return 'way'; @@ -12,7 +14,7 @@ function formatOSMType(sType, bExcludeExternal) { } Handlebars.registerHelper({ - shortOSMType: function(sType) { + shortOSMType: function (sType) { if (sType === 'node') return 'N'; if (sType === 'way') return 'W'; if (sType === 'relation') return 'R'; @@ -99,7 +101,7 @@ Handlebars.registerHelper({ return (iLevel < 15 ? iLevel : ''); }, formatMapIcon: function (sIcon) { - if (!sIcon) return; + if (!sIcon) return ''; var url = sIcon; if (!url.match(/^http/)) url = get_config_value('Images_Base_Url') + url; @@ -117,7 +119,8 @@ Handlebars.registerHelper({ if (aPlace.type && aPlace.type === 'yes' && aPlace.class) { return capitalize(aPlace.class.replace(/_/g, ' ')); - } else if (aPlace.type) { + } + if (aPlace.type) { return capitalize(aPlace.type.replace(/_/g, ' ')); } return ''; @@ -146,13 +149,10 @@ Handlebars.registerHelper({ return 'other: ' + iRank; }, tooManyHierarchyLinesWarning: function (aPlace) { - if (!aPlace.hierarchy) return; + if (!aPlace.hierarchy) return ''; - var c = 0; - for (var type in aPlace.hierarchy) { - c = c + type.length + 1; - } - if (c < 500) return; + var c = Object.keys(aPlace.hierarchy); + if (c < 500) return ''; return new Handlebars.SafeString( '

There are more child objects which are not shown.

' @@ -186,7 +186,9 @@ Handlebars.registerHelper({ var select = $('