2 Copyright (C)
2011 Pau Escrich
<pau@dabax.net
>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version
2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA
02110-
1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called
"COPYING".
24 luci.http.prepare_content(
"text/html")
26 local location = { unpack(luci.dispatcher.context.path) }
27 location[#location] =
"topology"
32 <script type=
"text/javascript" src=
"<%=resource%>/bmx6/js/raphael-min.js"></script>
33 <script type=
"text/javascript" src=
"<%=resource%>/bmx6/js/dracula_graffle.js"></script>
34 <script type=
"text/javascript" src=
"<%=resource%>/bmx6/js/jquery-1.4.2.min.js"></script>
35 <script type=
"text/javascript" src=
"<%=resource%>/bmx6/js/dracula_graph.js"></script>
37 <button id=
"redraw" onclick=
"redraw();">  redraw  
</button>
39 <div id=
"wait" style=
"text-align: center">
41 <img src=
"<%=resource%>/icons/loading.gif" />
42 <%:Collecting data...%
>
46 <div id=
"canvas" style=
"min-width:800px; min-height:800px"></div>
48 <script type=
"text/javascript">//<![CDATA[
51 XHR.get('<%=luci.dispatcher.build_url(unpack(location))%
>', null,
57 for (var i =
0; i < (data.length); i++)
62 for (var j =
0; j < (data[i].links.length); j++)
64 var key = (data[i].globalId < data[i].links[j].globalId)
65 ? data[i].globalId + '|' + data[i].links[j].globalId
66 : data[i].links[j].globalId + '|' + data[i].globalId;
68 var rxRate = data[i].links[j].rxRate;
69 var txRate = data[i].links[j].txRate;
71 if (!seen[key] && rxRate
>0 && txRate
>0)
73 g.addEdge(data[i].globalId, data[i].links[j].globalId,
74 { label: rxRate + '/' + txRate,
75 directed: false, stroke: '#aaaaaa', fill: '#ffffff',
76 'label-style': { 'font-size':
8 }});
81 //g.addEdge(data[i].router, data[i].neighbor,
82 // { label: data[i].label, directed: true, stroke: '#aaaaaa' });
84 //else if (data[i].router && data[i].gateway)
85 // g.addEdge(data[i].router, data[i].gateway,
86 // { label: 'leaf', stroke: '#cccccc' });
89 var canvas = document.getElementById('canvas');
91 var layouter = new Graph.Layout.Spring(g);
94 var divwait = document.getElementById(
"wait");
95 divwait.parentNode.removeChild(divwait);
97 var renderer = new Graph.Renderer.Raphael(canvas.id, g, canvas.offsetWidth, canvas.offsetHeight);
100 redraw = function() {