X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/538e9b96540c07059f725475c2b7fb80278c0dd6..302bbba7cfc04b0bc90fff9279c587545a9816c4:/src/handlebar_helpers.js?ds=sidebyside
diff --git a/src/handlebar_helpers.js b/src/handlebar_helpers.js
index 8970578..358ac36 100644
--- a/src/handlebar_helpers.js
+++ b/src/handlebar_helpers.js
@@ -1,154 +1,199 @@
-function formatOSMType(sType, bExcludeExternal)
-{
- if (sType == 'N') return 'node';
- if (sType == 'W') return 'way';
- if (sType == 'R') return 'relation';
+function formatOSMType(sType, bExcludeExternal) {
+ if (sType === 'N') return 'node';
+ if (sType === 'W') return 'way';
+ if (sType === 'R') return 'relation';
- if (!bExcludeExternal) return '';
+ if (!bExcludeExternal) return '';
- if (sType == 'T') return 'way';
- if (sType == 'I') return 'way';
+ if (sType === 'T') return 'way';
+ if (sType === 'I') return 'way';
- return '';
+ return '';
}
Handlebars.registerHelper({
- isaddresses_unused: function(aAddressLine) {
- return ((aAddressLine.isaddress && aAddressLine.isaddress == 'f') ? 'notused' : '');
- },
- // { osm_type: 'R', osm_id: 12345 }
- // relation 12345' + sOSMType + ' ' + aPlace.osm_id + ''
- );
- },
- /* en:London_Borough_of_Redbridge => https://en.wikipedia.org/wiki/London_Borough_of_Redbridge */
- wikipediaLink: function(aPlace) {
- if (! aPlace.calculated_wikipedia) return '';
-
- var parts = aPlace.calculated_wikipedia.split(':', 2);
-
- var sTitle = Handlebars.escapeExpression(aPlace.calculated_wikipedia),
- sLanguage = Handlebars.escapeExpression(parts[0]),
- sArticle = Handlebars.escapeExpression(parts[1]);
-
- return new Handlebars.SafeString(
- '' + sTitle + ''
- );
- },
- // { osm_type: 'R', osm_id: 12345 }
- // details
- detailsLink: function(aFeature, sTitle) {
- if (!aFeature) return '';
- if (!aFeature.place_id) return '';
-
- sTitle = 'details >';
- var sTitle = Handlebars.escapeExpression(sTitle);
-
- return new Handlebars.SafeString(
- '' + (sTitle ? sTitle : aFeature.place_id ) + ''
- );
- },
- coverageType: function(aPlace) {
- return (aPlace.isarea ? 'Polygon' : 'Point');
- },
- // fDistance is in meters
- formatDistance: function(fDistanceMeters) {
- if (fDistanceMeters < 1) return '0';
-
- var formatted = (fDistanceMeters >= 1000) ?
- Math.round(fDistanceMeters/1000, 1) + ' km' :
- Math.round(fDistanceMeters, 0) + ' m';
-
- return new Handlebars.SafeString(
- '~' + formatted + ''
- );
- },
- // mark partial tokens (those starting with a space) with a star for readability
- formatKeywordToken: function(sToken) {
- return (sToken[0] == ' ' ? '*' : '') + Handlebars.escapeExpression(sToken);
- },
- // Any over 15 are invalid data in OSM anyway
- formatAdminLevel: function(iLevel) {
- return (iLevel < 15 ? iLevel : '');
- },
- formatMapIcon: function(sIcon) {
- if (!sIcon) return;
-
- var url = Nominatim_Config.Images_Base_Url + sIcon;
-
- return new Handlebars.SafeString(
- ''
- );
- },
- formatLabel: function(aPlace) {
- if (aPlace.label) return aPlace.label;
-
- function capitalize(s)
- {
- return s && s[0].toUpperCase() + s.slice(1);
- }
-
- if (aPlace.type && aPlace.type === 'yes') {
- return capitalize(aPlace.class.replace(/_/g, ' '));
- } else {
- return capitalize(aPlace.type.replace(/_/g, ' '));
- }
- },
- tooManyHierarchyLinesWarning: function(aPlace) {
- if (!aPlace.hierarchy) return;
-
- var c = 0;
- for (var type in aPlace.hierarchy) {
- c = c + type.length+1;
- }
- if (c < 500) return;
-
- return new Handlebars.SafeString(
- '
There are more child objects which are not shown.
'
- );
- },
- zoomLevels: function(iSelectedZoom) {
- var aZoomLevels = [
- /* 0 */ 'Continent / Sea',
- /* 1 */ '',
- /* 2 */ '',
- /* 3 */ 'Country',
- /* 4 */ '',
- /* 5 */ 'State',
- /* 6 */ 'Region',
- /* 7 */ '',
- /* 8 */ 'County',
- /* 9 */ '',
- /* 10 */ 'City',
- /* 11 */ '',
- /* 12 */ 'Town / Village',
- /* 13 */ '',
- /* 14 */ 'Suburb',
- /* 15 */ '',
- /* 16 */ 'Street',
- /* 17 */ '',
- /* 18 */ 'Building',
- /* 19 */ '',
- /* 20 */ '',
- /* 21 */ ''
- ];
-
- var select = $('