summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-olsr-viz/htdocs/cgi-bin
diff options
context:
space:
mode:
authorManuel Munz <freifunk@somakoma.de>2010-12-11 17:08:03 +0000
committerManuel Munz <freifunk@somakoma.de>2010-12-11 17:08:03 +0000
commit7210e6470849e003e3cb2df80ca8b4f3966a6239 (patch)
tree02e9129ca9b4dee5d06d3b7c5181ecc854137d04 /applications/luci-olsr-viz/htdocs/cgi-bin
parent75e1a4cfbcedaa0185c087b3fae35e847500c3fa (diff)
applications: Add luci-olsr-viz (ported from fff-1.7.4)
Diffstat (limited to 'applications/luci-olsr-viz/htdocs/cgi-bin')
-rwxr-xr-xapplications/luci-olsr-viz/htdocs/cgi-bin/olsr-viz.sh40
-rwxr-xr-xapplications/luci-olsr-viz/htdocs/cgi-bin/vizdata.sh48
2 files changed, 88 insertions, 0 deletions
diff --git a/applications/luci-olsr-viz/htdocs/cgi-bin/olsr-viz.sh b/applications/luci-olsr-viz/htdocs/cgi-bin/olsr-viz.sh
new file mode 100755
index 0000000000..86cb87ca67
--- /dev/null
+++ b/applications/luci-olsr-viz/htdocs/cgi-bin/olsr-viz.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+echo Content-type: text/html
+echo
+
+cat << EOF
+<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
+var css=document.styleSheets[0];
+if (null!=css.insertRule) {
+css.insertRule(".label {color:black;background-color:white}", css.cssRules.length);
+}
+else {
+css.addRule(".label", "color:black");
+css.addRule(".label", "background-color:white");
+}
+</SCRIPT>
+<SCRIPT SRC="/luci-static/resources/olsr-viz.js" LANGUAGE="JavaScript1.2" TYPE="text/javascript"></SCRIPT>
+<DIV ID="main"
+STYLE="width: 100%; height: 93%; border: 1px solid #ccc; margin-left:auto; margin-right:auto; text-align:center; overflow: scroll">
+<DIV ID="edges" STYLE="width: 1px; height: 1px; position: relative; z-index:2"></DIV>
+<DIV ID="nodes" STYLE="width: 1px; height: 1px; position: relative; z-index:4"></DIV>
+</DIV>
+<DIV STYLE="z-index:99">
+<FORM ACTION="">
+<P><B TITLE="Bestimmt die Vergrößerungsstufe.">Zoom</B>&nbsp;<A HREF="javascript:set_scale(scale+0.1)">+</A>&nbsp;<A HREF="javascript:set_scale(scale-0.1)">&ndash;</A>&nbsp;<INPUT ID="zoom" NAME="zoom" TYPE="text" VALUE="2.0" SIZE="5" ONCHANGE="set_scale()">&nbsp;
+| &nbsp;<B TITLE="Beschränkt die Anzeige auf eine maximale Hop-Entfernung.">Metrik</B>&nbsp;<A HREF="javascript:set_maxmetric(maxmetric+1)">+</A>&nbsp;<A HREF="javascript:if(0<maxmetric)set_maxmetric(maxmetric-1)">&ndash;</A>&nbsp;<INPUT ID="maxmetric" NAME="maxmetric" TYPE="text" VALUE="3" SIZE="4" ONCHANGE="set_maxmetric(this.value)">&nbsp;
+| &nbsp;<B TITLE="Schaltet die automatischen Layout-Optimierung ein.">Optimierung</B><INPUT ID="auto_declump" NAME="auto_declump" TYPE="checkbox" ONCHANGE="set_autodeclump(this.checked)" CHECKED="CHECKED">&nbsp;
+| &nbsp;<B TITLE="Zeige Hostnamen an.">Hostnamen</B><INPUT ID="show_hostnames" NAME="show_hostnames" TYPE="checkbox" ONCHANGE="set_showdesc(this.checked)" CHECKED="CHECKED">&nbsp;
+| &nbsp;<A HREF="javascript:viz_save()" TITLE="Speichert die aktuellen Einstellungen in einem Cookie.">Speichern</A>&nbsp;
+| &nbsp;<A HREF="javascript:viz_reset()" TITLE="Startet das Viz-Skriptprogramm neu.">Zur&uuml;cksetzen</A></P>
+</FORM></DIV>
+<SPAN ID="debug" STYLE="visibility:hidden;"></SPAN>
+<IFRAME ID="RSIFrame" NAME="RSIFrame" STYLE="border:0px; width:0px; height:0px; visibility:hidden;">
+</IFRAME>
+<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
+
+viz_setup("RSIFrame","main","nodes","edges");
+viz_update();
+
+</SCRIPT>
+EOF
diff --git a/applications/luci-olsr-viz/htdocs/cgi-bin/vizdata.sh b/applications/luci-olsr-viz/htdocs/cgi-bin/vizdata.sh
new file mode 100755
index 0000000000..5a74f2be94
--- /dev/null
+++ b/applications/luci-olsr-viz/htdocs/cgi-bin/vizdata.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+echo Content-type: text/html
+echo
+
+cat<<EOF
+<HTML>
+<HEAD>
+ <TITLE>OLSR-VIZ Data</TITLE>
+ <META CONTENT="text/html; charset=iso-8859-1" HTTP-EQUIV="Content-Type">
+ <META CONTENT="no-cache" HTTP-EQUIV="cache-control">
+</HEAD>
+<BODY>
+
+<script langauge='JavaScript1.2' type='text/javascript'>
+EOF
+
+# sed + txtinfo plugin
+re_ip='[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}'
+re_sep='[[:space:]]\{1,\}'
+re_nosep='[^[:space:]]\{1,\}'
+wget http://127.0.0.1:2006/all -qO - | sed -n "
+/^Table: Links$/,/^$/ {
+s# # - #g
+s#\($re_ip\)$re_sep\($re_ip\)\($re_sep$re_nosep\)\{3\}$re_sep\($re_nosep\)#parent.touch_edge(parent.touch_node('\1').set_metric(1).update(),parent.touch_node('\2').set_metric(1).update(),'\4');#p
+}
+/^Table: Topology$/,/^$/ {
+s#\($re_ip\)$re_sep\($re_ip\)\($re_sep$re_nosep\)\{2\}$re_sep\($re_nosep\)#parent.touch_edge(parent.touch_node('\1').update(),parent.touch_node('\2').update(),'\4');#p
+}
+/^Table: HNA$/,/^$/ {
+s#\($re_ip\)/\([0-9]\{1,\}\)$re_sep\($re_ip\)#parent.touch_hna(parent.touch_node('\3'),'\1','\2');#p
+}
+/^Table: Routes$/,/^$/ {
+s#\($re_ip\)/32$re_sep$re_nosep$re_sep\($re_nosep\).*#parent.touch_node('\1').set_metric('\2').update();#p
+}
+"
+
+hosts=$(uci show olsrd|grep hosts_file|cut -d "=" -f 2)
+if [ -n $hosts ]; then
+sed -n "
+s#\($re_ip\)$re_sep\($re_nosep\)$re_sep.*#parent.touch_node('\1').set_desc('\2');#p
+" < $hosts
+fi
+
+cat<<EOF
+ parent.viz_callback();
+</script>
+</BODY></HTML>
+EOF