From 36e99c43cedeb557fb911064a3311bc99b8a44a0 Mon Sep 17 00:00:00 2001 From: marc tobias Date: Thu, 31 Oct 2019 17:13:43 +0100 Subject: [PATCH] HTML page with search form when /details.php called without params --- lib/template/details-index-html.php | 55 +++++++++++++++++++++++++++++ website/css/details.css | 11 ++++++ website/details.php | 5 +++ website/js/nominatim-ui.js | 24 +++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 lib/template/details-index-html.php diff --git a/lib/template/details-index-html.php b/lib/template/details-index-html.php new file mode 100644 index 00000000..640a212c --- /dev/null +++ b/lib/template/details-index-html.php @@ -0,0 +1,55 @@ + + + + + + + + +
+
+
+ +

Show details for place

+ +
+

Search by place id

+ +
+ + +
+
+ +
+

Search by OSM type and OSM id

+ +
+ + + + +
+
+ +
+

Search by openstreetmap.org URL

+ +
+ + + + +
+
+ +
+
+
+ + + + + diff --git a/website/css/details.css b/website/css/details.css index 171de42a..8f21c310 100644 --- a/website/css/details.css +++ b/website/css/details.css @@ -52,6 +52,17 @@ tr.all-columns td { margin: 10px 0; } +#details-index-page .search-form { + padding: 20px 10px; + margin: 2em 0; +} +#details-index-page .search-form h4 { + margin-top: 0; +} +#details-index-page .search-form .form-control{ + width: 30em; +} + footer { text-align: center; padding: 2em 0; diff --git a/website/details.php b/website/details.php index cb371e6b..44d4956b 100644 --- a/website/details.php +++ b/website/details.php @@ -30,6 +30,11 @@ $oDB->connect(); $sLanguagePrefArraySQL = $oDB->getArraySQL($oDB->getDBQuotedList($aLangPrefOrder)); +if ($sOutputFormat == 'html' && !$sPlaceId && !$sOsmType) { + include(CONST_BasePath.'/lib/template/details-index-html.php'); + exit; +} + if ($sOsmType && $iOsmId > 0) { $sSQL = 'SELECT place_id FROM placex WHERE osm_type = :type AND osm_id = :id'; // osm_type and osm_id are not unique enough diff --git a/website/js/nominatim-ui.js b/website/js/nominatim-ui.js index e96ebd25..32e7cbda 100644 --- a/website/js/nominatim-ui.js +++ b/website/js/nominatim-ui.js @@ -273,6 +273,30 @@ jQuery(document).ready(function(){ }); +jQuery(document).ready(function(){ + + if ( !$('#details-index-page').length ){ return; } + + $('#form-by-type-and-id,#form-by-osm-url').on('submit', function(e){ + e.preventDefault(); + + var val = $(this).find('input[type=edit]').val(); + var matches = val.match(/^\s*([NWR])(\d+)\s*$/i); + + if (!matches) { + matches = val.match(/\/(relation|way|node)\/(\d+)\s*$/); + } + + if (matches) { + $(this).find('input[name=osmtype]').val(matches[1].charAt(0).toUpperCase()); + $(this).find('input[name=osmid]').val(matches[2]); + $(this).get(0).submit(); + } else { + alert('invalid input'); + } + }); +}); + jQuery(document).ready(function(){ if ( !$('#details-page').length ){ return; } -- 2.39.5