From 5b5ce97a1a0a8e2bac0b875baddcd59fd8b54b67 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Sat, 25 Apr 2020 17:34:33 +0200 Subject: [PATCH] Fix search behavior Before, it was always searching for the current term without the last entered (or with the last deleted) character. This behavior is fixed now. Also, an empty query will now match (hopefully) nothing instead of everything. --- htdocs/mapscript.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js index ff1d22e..57fa0f8 100644 --- a/htdocs/mapscript.js +++ b/htdocs/mapscript.js @@ -292,7 +292,7 @@ function toggle_search() { search_element.style.overflow = "scroll"; search_element.style.padding = "6px"; search_element.style.height = "100%"; - search_element.innerHTML = '
' ; + search_element.innerHTML = '
' ; } td = document.getElementById('windowtr').insertCell(0); @@ -302,7 +302,7 @@ function toggle_search() { td.id = "searchbar"; td.appendChild(search_element); - document.getElementById('search_query').focus(); + document.getElementById('search_query').select(); } function htmlEntities(str) { @@ -321,7 +321,9 @@ var default_street_color = "#3388ff"; function search(e) { var query = document.getElementById("search_query").value; document.getElementById('search_results').innerHTML = ""; - if (query.length > 0 || e.key == "Enter") { + if (true) { + if (query.length == 0) + query = "!@#$%^&"; // Cheap workaround to (hopefully) match nothing results = document.createElement("ul"); for (var i = 0; i < layers._layers.length; i++) { if (!layers._layers[i].layer._layers)