diff options
author | Markus Koch <markus@notsyncing.net> | 2020-04-25 17:34:33 +0200 |
---|---|---|
committer | Markus Koch <markus@notsyncing.net> | 2020-04-25 17:34:33 +0200 |
commit | 5b5ce97a1a0a8e2bac0b875baddcd59fd8b54b67 (patch) | |
tree | e0fa4a302bedfc20a319d7c017ce1509a6bd299e | |
parent | d229044ebfaf0a2d09d002c4c490de2d9248dcfd (diff) | |
download | lifomapserver-5b5ce97a1a0a8e2bac0b875baddcd59fd8b54b67.tar.gz lifomapserver-5b5ce97a1a0a8e2bac0b875baddcd59fd8b54b67.tar.bz2 lifomapserver-5b5ce97a1a0a8e2bac0b875baddcd59fd8b54b67.zip |
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.
-rw-r--r-- | htdocs/mapscript.js | 8 |
1 files 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 = '<input style="width:100%;" id="search_query" name="lifo_map_search" type="search" placeholder="Start typing to search..." onkeypress="search(event)"><div id="search_results"></div>' ; + search_element.innerHTML = '<input style="width:100%;" id="search_query" name="lifo_map_search" type="search" placeholder="Start typing to search..." oninput="search(event)"><div id="search_results"></div>' ; } 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) |