]> git.openstreetmap.org Git - nominatim-ui.git/blobdiff - src/handlebar_helpers.js
jquery 3.4.0 -> 3.4.1
[nominatim-ui.git] / src / handlebar_helpers.js
index b40b11a88a1afcea949a3e680e10054ff99a0302..20ecb7c132711815b073e94bc3e46ce36213adfe 100644 (file)
@@ -62,7 +62,7 @@ Handlebars.registerHelper({
         sTitle = Handlebars.escapeExpression(sTitle || sOSMType + ' ' + aFeature.osm_id);
 
         return new Handlebars.SafeString(
-            '<a href="details.html?osmtype=' + aFeature.osm_type + '&osmid=' + aFeature.osm_id + '&class=' + aFeature.class + '">' + sTitle + '</a>'
+            '<a href="details.html?osmtype=' + aFeature.osm_type + '&osmid=' + aFeature.osm_id + '&class=' + aFeature.category + '">' + sTitle + '</a>'
         );
     },
     coverageType: function(aPlace) {
@@ -91,7 +91,8 @@ Handlebars.registerHelper({
     formatMapIcon: function(sIcon) {
         if (!sIcon) return;
         
-        var url = Nominatim_Config.Images_Base_Url + sIcon;
+        var url = sIcon;
+        if (!url.match(/^http/)) url = get_config_value('Images_Base_Url') + url;
 
         return new Handlebars.SafeString(
             '<img class="mapicon" src="' + url + '" alt="' + sIcon + '"/>'
@@ -111,6 +112,47 @@ Handlebars.registerHelper({
             return capitalize(aPlace.type.replace(/_/g, ' '));
         }
     },
+    formatSearchRank: function(iRank) {
+        // same as
+        // https://github.com/openstreetmap/Nominatim/blob/master/sql/functions.sql
+        // get_searchrank_label()
+
+        if (iRank < 2) {
+            return 'continent';
+        } else if (iRank < 4) {
+            return 'sea';
+        } else if (iRank < 8) {
+            return 'country';
+        } else if (iRank < 12) {
+            return 'state';
+        } else if (iRank < 16) { 
+            return 'county';
+        } else if (iRank == 16) {
+            return 'city';
+        } else if (iRank == 17) {
+            return 'town / island';
+        } else if (iRank == 18) {
+            return 'village / hamlet';
+        } else if (iRank == 20) {
+            return 'suburb';
+        } else if (iRank == 21) {
+            return 'postcode area';
+        } else if (iRank == 22) {
+            return 'croft / farm / locality / islet';
+        } else if (iRank == 23) {
+            return 'postcode area';
+        } else if (iRank == 25) {
+            return 'postcode point';
+        } else if (iRank == 26) {
+            return 'street / major landmark';
+        } else if (iRank == 27) {
+            return 'minory street / path';
+        } else if (iRank == 28) {
+            return 'house / building';
+        } else {
+            return 'other: ' + iRank;
+        }
+    },
     tooManyHierarchyLinesWarning: function(aPlace) {
         if (!aPlace.hierarchy) return;