]> git.openstreetmap.org Git - nominatim-ui.git/commitdiff
Set HTML title for all pages
authormarc tobias <mtmail@gmx.net>
Fri, 21 Feb 2020 17:27:32 +0000 (18:27 +0100)
committermarc tobias <mtmail@gmx.net>
Fri, 21 Feb 2020 17:27:32 +0000 (18:27 +0100)
TODO.md
dist/assets/js/nominatim-ui.js
src/assets/js/base.js
src/assets/js/detailpage.js
src/assets/js/searchpage.js

diff --git a/TODO.md b/TODO.md
index dbb1a9f7b6e7f46ed972b08cc1ac3bdab825d195..5e2a2959d2bc9b9b561c99c755a68b89ffb88a9e 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -7,14 +7,13 @@
 
 * pagination. API returns an array without indication if more results exist
 * API returns category, type, but without admin_level we can't derive e.g. state,country
-* seeting acceptlanguage whichout a server component https://github.com/dansingerman/jQuery-Browser-Language
+* setting accept-language without a server component https://github.com/dansingerman/jQuery-Browser-Language
 
 ## Nice-to-have
 
 * support nearlat,nearlon parameters
 * should images/mapicons/ be served from API server or this repo?
 * different content for official OSM, e.g. github urls
-* set HTML title
 * cache `update_data_date` result somehow?
 * a new search causes a new pageview
 * add tests with fixtures
index f94bc7538d6b5916540d3b3c7650301df1aa0e82..1a7ee696ccd62e789c4f519ce27d7ca2d968f437 100644 (file)
@@ -83,6 +83,14 @@ function render_template(el, template_name, page_context) {
   el.html(html);
 }
 
+function update_html_title(title) {
+  var prefix = '';
+  if (title && title.length > 1) {
+    prefix = title + ' | ';
+  }
+  $('head title').text(prefix + 'OpenStreetMap Nominatim');
+}
+
 function show_error(html) {
   $('#error-overlay').html(html).show();
 }
@@ -172,6 +180,11 @@ jQuery(document).ready(function () {
       var context = { aPlace: aFeature, base_url: location.search };
 
       render_template($('main'), 'detailspage-template', context);
+      if (api_request_params.place_id) {
+        update_html_title('Details for ' + api_request_params.place_id);
+      } else {
+        update_html_title('Details for ' + api_request_params.osmtype + api_request_params.osmid);
+      }
 
       update_data_date();
 
@@ -508,7 +521,7 @@ jQuery(document).ready(function () {
       iZoom: (search_params.get('zoom') > 1 ? api_request_params.zoom : get_config_value('Reverse_Default_Search_Zoom'))
     };
 
-
+    update_html_title();
     if (api_request_params.lat && api_request_params.lon) {
 
       fetch_from_api('reverse', api_request_params, function (aPlace) {
@@ -520,6 +533,7 @@ jQuery(document).ready(function () {
         context.aPlace = aPlace;
 
         render_template($('main'), 'reversepage-template', context);
+        update_html_title('Reverse result for ' + api_request_params.lat + ',' + api_request_params.lon);
 
         init_map_on_search_page(
           is_reverse_search,
@@ -566,6 +580,7 @@ jQuery(document).ready(function () {
         context.aSearchResults = aResults;
 
         render_template($('main'), 'searchpage-template', context);
+        update_html_title('Result for ' + api_request_params.q);
 
         init_map_on_search_page(is_reverse_search, aResults, get_config_value('Map_Default_Lat'), get_config_value('Map_Default_Lon'), get_config_value('Map_Default_Zoom'));
 
index a56f40d5a8e60c1944feabb119868f5446edcd10..c9635fbf712f7b540900947f4e37ef738ae2aa8f 100644 (file)
@@ -83,6 +83,14 @@ function render_template(el, template_name, page_context) {
   el.html(html);
 }
 
+function update_html_title(title) {
+  var prefix = '';
+  if (title && title.length > 1) {
+    prefix = title + ' | ';
+  }
+  $('head title').text(prefix + 'OpenStreetMap Nominatim');
+}
+
 function show_error(html) {
   $('#error-overlay').html(html).show();
 }
index 09a8ce105d12c218aa419073d4517b21243c2b1c..73591feae2b3e0c5f51fd5f6cb6358454d78d7ec 100644 (file)
@@ -68,6 +68,11 @@ jQuery(document).ready(function () {
       var context = { aPlace: aFeature, base_url: location.search };
 
       render_template($('main'), 'detailspage-template', context);
+      if (api_request_params.place_id) {
+        update_html_title('Details for ' + api_request_params.place_id);
+      } else {
+        update_html_title('Details for ' + api_request_params.osmtype + api_request_params.osmid);
+      }
 
       update_data_date();
 
index b970afc4a64b08c72a956f2a2ebd09ea6224ebbd..01b8fde65bf5b4d55eefe2537e0586c689a79cf2 100755 (executable)
@@ -304,7 +304,7 @@ jQuery(document).ready(function () {
       iZoom: (search_params.get('zoom') > 1 ? api_request_params.zoom : get_config_value('Reverse_Default_Search_Zoom'))
     };
 
-
+    update_html_title();
     if (api_request_params.lat && api_request_params.lon) {
 
       fetch_from_api('reverse', api_request_params, function (aPlace) {
@@ -316,6 +316,7 @@ jQuery(document).ready(function () {
         context.aPlace = aPlace;
 
         render_template($('main'), 'reversepage-template', context);
+        update_html_title('Reverse result for ' + api_request_params.lat + ',' + api_request_params.lon);
 
         init_map_on_search_page(
           is_reverse_search,
@@ -362,6 +363,7 @@ jQuery(document).ready(function () {
         context.aSearchResults = aResults;
 
         render_template($('main'), 'searchpage-template', context);
+        update_html_title('Result for ' + api_request_params.q);
 
         init_map_on_search_page(is_reverse_search, aResults, get_config_value('Map_Default_Lat'), get_config_value('Map_Default_Lon'), get_config_value('Map_Default_Zoom'));