X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/be5f5c2733a73d7a548be2f461f03fef6bfa499b..c5d0923efd3addedf075592895d2fef3f8796e5e:/src/handlebar_helpers.js diff --git a/src/handlebar_helpers.js b/src/handlebar_helpers.js index 3ece852..36deacd 100644 --- a/src/handlebar_helpers.js +++ b/src/handlebar_helpers.js @@ -13,6 +13,13 @@ function formatOSMType(sType, bExcludeExternal) { return ''; } +function formatShortOSMType(sType) { + if (sType === 'node') return 'N'; + if (sType === 'way') return 'W'; + if (sType === 'relation') return 'R'; + return ''; +} + function getIcon(aPlace) { // equivalent to PHP Nominatim::ClassTypes::getIcon // covers 83 of 214 available icon filenames, e.g. transport_roundabout_anticlockwise @@ -115,10 +122,7 @@ Handlebars.registerHelper({ return formatOSMType(sType, bExcludeExternal); }, shortOSMType: function (sType) { - if (sType === 'node') return 'N'; - if (sType === 'way') return 'W'; - if (sType === 'relation') return 'R'; - return ''; + return formatShortOSMType(sType); }, // { osm_type: 'R', osm_id: 12345 } // relation 12345' + sTitle + '' ); }, - // { osm_type: 'R', osm_id: 12345 } - // details - detailsLink: function (aFeature, sTitle) { - if (!aFeature) return ''; - if (!aFeature.place_id) return ''; - - var sTitleEscaped = Handlebars.escapeExpression(sTitle || 'details >'); - - return new Handlebars.SafeString( - '' + sTitleEscaped + '' - ); - }, - detailsPermaLink: function (aFeature, sTitle) { + // 'details.html?osmtype=R&osmid=2181874&class=boundary' + detailsURL: function (aFeature) { if (!aFeature) return ''; - var sOSMType = formatOSMType(aFeature.osm_type, false); + var sOSMType = aFeature.osm_type; + if (sOSMType && sOSMType.length !== 1) { + sOSMType = formatShortOSMType(aFeature.osm_type, false); // node => N + } if (!sOSMType) return ''; - var sTitleEscaped = Handlebars.escapeExpression(sTitle || sOSMType + ' ' + aFeature.osm_id); - - var sURL = 'details.html?osmtype=' + aFeature.osm_type + '&osmid=' + aFeature.osm_id; - if (aFeature.category) { + var sURL = 'details.html?osmtype=' + sOSMType + '&osmid=' + aFeature.osm_id; + if (aFeature.class) { + sURL = sURL + '&class=' + aFeature.class; + } else if (aFeature.category) { sURL = sURL + '&class=' + aFeature.category; } - - return new Handlebars.SafeString( - '' + sTitleEscaped + '' - ); + return sURL; }, formatPlaceType: function (aPlace) { var sOut = aPlace.class + ':' + aPlace.type;