added clear database option
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 15 Dec 2010 18:15:41 +0000 (18:15 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 15 Dec 2010 18:15:41 +0000 (18:15 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@275 01035d8c-6547-0410-b346-abe4f91aad63

dilimesh/README.txt
dilimesh/cgi-bin/cleardb.cgi [new file with mode: 0755]
dilimesh/dilimesh/dilimesh.html

index 5dba91d1f43486b52a2e7e7e99c105e9682a1a8a..398d6818e4f552e6186484d91db1b9f615ba672a 100644 (file)
@@ -170,7 +170,7 @@ Installation
 
   Configure you nodes to use the visualisation server:
   
-    # cat /etc/confog/batman  
+    # cat /etc/config/batman  
     config batmand general
         option interface                ath0
         option announce
diff --git a/dilimesh/cgi-bin/cleardb.cgi b/dilimesh/cgi-bin/cleardb.cgi
new file mode 100755 (executable)
index 0000000..fa4433c
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+# cleardb.cgi
+# David Rowe 15 Dec 2010
+#
+# CGI to delete entire node database
+
+cat <<EOF
+Content-type: text/html
+
+<html>
+<head>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="-1"></head></head>
+<body>
+EOF
+
+# path to node database text file
+
+P=/var/www/dilimesh
+rm $P/nodes.txt
+
+cat <<EOF
+</body>
+</html>
+EOF
index 662ca242028805273ed45619e6139a1f0fcff05f..1c002295ca7d4e6ffb1ccf8e1a742fc01e142011 100644 (file)
       // delete node from text file
 
       var url;
-      url = "/cgi-bin/delnode.cgi?" + "lat=" +  this.position.ya + "&" + "lng=" +  this.position.za;
+      url = "/cgi-bin/delnode.cgi?" + "lat=" +  this.position.lat() + "&" + "lng=" +  this.position.lng();
       downloadUrl(url, function(doc) { });
       this.setMap(null);
 
   // Grab a bunch of config info from our cookie
 
   function getCookie() {
-
+                       
     if (document.cookie.length > 0) {
       cookieStart = document.cookie.indexOf(cookiename + "=");
 
   }
 
 
+  // clear database and set cookie to defaults
+
+  function clearDatabase() {
+
+    // call CGI to rm nodes.txt
+
+    downloadUrl("/cgi-bin/cleardb.cgi", function(doc) { });
+    nodes = [];    
+
+    // I would really like to clear cookie but can't work out how, so
+    // set to defaults instead, 
+
+    var myLatLng = new google.maps.LatLng(0, 0);
+    map.setCenter(myLatLng);
+    map.setZoom(2);
+    update_enable = 0;                          
+ }
+
+
   // called when we click to add a node on map
 
   function placeMarker(location, ip, isNewNode) {
           <td width="30%"></td>
           <td width="50"><input type="submit" value="Set" onclick="setUpdateTime()"></td>
         </tr>
+        <tr>
+          <td></td>
+         <td>Clear Database</td>
+          <td></td>
+          <td width="30%"></td>
+          <td width="60"><input type="submit" value="Clear" onclick="clearDatabase()"></td>
+        </tr>
         <tr>
          <td></td>
           <td>Debug Messages</td>