changeset 1936:fe32111858f6

Show number of currently selected target maps in the search.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 13 Nov 2017 05:36:44 +0200
parents de876a893568
children f0311e3a9b44
files www/search.js www/search.php
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/www/search.js	Mon Nov 13 05:36:09 2017 +0200
+++ b/www/search.js	Mon Nov 13 05:36:44 2017 +0200
@@ -180,6 +180,16 @@
 }
 
 
+function mapUpdateMapCount()
+{
+  var elem = document.getElementById("mapInfo");
+  var l = mapGetSelectedMaps();
+  elem.innerHTML = (l.length == 0) ?
+    "No maps selected!" :
+    "<b>"+ l.length +"</b> map"+ (l.length > 1 ? "s" : "") +" selected.";
+}
+
+
 function mapGetData()
 {
   var tmpWS = new WebSocket(mapServer);
@@ -220,6 +230,14 @@
 
         var elem = document.getElementById("mapList");
         elem.innerHTML = str;
+
+        for (var i = 0; i < results.length; i++)
+        {
+          var res = results[i];
+          mapAddEvent("map_" + res[0], "change", mapUpdateMapCount);
+        }
+
+        mapUpdateMapCount();
       }
       else
         fieldRes.innerHTML = "ERROR: "+ results;
@@ -385,6 +403,8 @@
       var elem = document.getElementById("map_"+ res[0]);
       elem.checked = same;
     }
+
+    mapUpdateMapCount();
   });
 
   // Listener for location name search
--- a/www/search.php	Mon Nov 13 05:36:09 2017 +0200
+++ b/www/search.php	Mon Nov 13 05:36:44 2017 +0200
@@ -28,6 +28,7 @@
   <textarea id="mapPattern" cols="30" rows="15"></textarea>
   <div id="controls">
     <div id="mapList">LOADING MAP LIST...</div>
+    <span id="mapInfo"></span>
     <button id="btnMaps" type="button" title="Reset or clear the map selection to be searched. Just click it to see what happens.">C^</button>
     <button class="large" id="btnClear" type="button" title="Clear current search results and map search pattern. Does NOT reset the selected maps.">Clear search</button>
     <button class="large" id="btnMapSearch" type="button" title="Perform map search with the currently selected maps.">Search</button>