From 2883c58e8ab357c4d87c12ea7f3134cd24f4dd1c Mon Sep 17 00:00:00 2001 From: drowe67 Date: Wed, 15 Dec 2010 18:15:41 +0000 Subject: [PATCH] added clear database option git-svn-id: https://svn.code.sf.net/p/freetel/code@275 01035d8c-6547-0410-b346-abe4f91aad63 --- dilimesh/README.txt | 2 +- dilimesh/cgi-bin/cleardb.cgi | 26 ++++++++++++++++++++++++++ dilimesh/dilimesh/dilimesh.html | 30 ++++++++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100755 dilimesh/cgi-bin/cleardb.cgi diff --git a/dilimesh/README.txt b/dilimesh/README.txt index 5dba91d1..398d6818 100644 --- a/dilimesh/README.txt +++ b/dilimesh/README.txt @@ -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 index 00000000..fa4433c9 --- /dev/null +++ b/dilimesh/cgi-bin/cleardb.cgi @@ -0,0 +1,26 @@ +#!/bin/sh +# cleardb.cgi +# David Rowe 15 Dec 2010 +# +# CGI to delete entire node database + +cat < + + + + + +EOF + +# path to node database text file + +P=/var/www/dilimesh +rm $P/nodes.txt + +cat < + +EOF diff --git a/dilimesh/dilimesh/dilimesh.html b/dilimesh/dilimesh/dilimesh.html index 662ca242..1c002295 100644 --- a/dilimesh/dilimesh/dilimesh.html +++ b/dilimesh/dilimesh/dilimesh.html @@ -677,7 +677,7 @@ // 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); @@ -711,7 +711,7 @@ // Grab a bunch of config info from our cookie function getCookie() { - + if (document.cookie.length > 0) { cookieStart = document.cookie.indexOf(cookiename + "="); @@ -747,6 +747,25 @@ } + // 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) { @@ -902,6 +921,13 @@ + + + Clear Database + + + + Debug Messages -- 2.25.1