Merry christmas! Redesign of JavaScript code and many other things (graph, nodes...
[feed/routing.git] / files / usr / lib / lua / luci / view / bmx6 / neighbours_j.htm
1 <%+header%>
2 <script type="text/javascript">//<![CDATA[
3
4 var displayExtraInfo = function ( id ) {
5
6 document.getElementById('extra-info').innerHTML = document.getElementById(id).innerHTML;
7 }
8 XHR.poll(5, '/cgi-bin/bmx6-info', { '$neighbours': '' },
9 function(x, st)
10 {
11 var originators = st.neighbours[0].originators;
12 var descriptions = st.neighbours[1].descriptions;
13
14 var tb = document.getElementById('descriptions_table');
15
16 if ( originators.length != descriptions.length )
17 {
18 var tr = tb.insertRow(-1);
19 tr.className = 'cbi-section-table-row';
20 var td = tr.insertCell(-1);
21 td.colSpan = 7;
22 td.innerHTML = '<em><br /><%:Some problem with JSON: lenght of originators and descriptions different. %></em>';
23 td.innerHTML += '<em><%: Please perform a manually cache flush from a terminal: bmx6 -c --flushAll %></em>'
24 return 1;
25 }
26
27 if ( originators && descriptions && tb)
28 {
29 /* clear all rows */
30 while( tb.rows.length > 1 )
31 tb.deleteRow(1);
32
33 for( var i = 0; i < descriptions.length; i++ )
34 {
35 var tr = tb.insertRow(-1);
36 var nodename = descriptions[i].DESC_ADV.globalId.replace(/\.[^\.]+$/,"");
37 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
38 tr.insertCell(-1).innerHTML = '<a onclick="displayExtraInfo(\'ip-'+i+'\')"><img src=\"<%=resource%>/cbi/help.gif\" /></a>';
39 tr.insertCell(-1).innerHTML = nodename;
40
41 var extensions = descriptions[i].DESC_ADV.extensions;
42
43 //Looking for the extensions
44 var hna6 = [];
45 var tun4in6 = [];
46 var tun6 = [];
47 for( var e = 0; e < extensions.length; e++)
48 {
49 if( extensions[e].HNA6_EXTENSION )
50 {
51 hna6 = extensions[e].HNA6_EXTENSION;
52 }
53 if ( extensions[e].TUN4IN6_NET_EXTENSION )
54 {
55 tun4in6 = extensions[e].TUN4IN6_NET_EXTENSION;
56 }
57 }
58
59 var gateways = '<ul>';
60 for ( var t = 0; t < tun4in6.length; t++)
61 {
62 if ( tun4in6[t].networklen == "32" )
63 gateways += '<li><a href="http://' + tun4in6[t].network + '">' + tun4in6[t].network + '</a></li>';
64 else
65 gateways += "<li>"+tun4in6[t].network+'/'+tun4in6[t].networklen + ' | ' + tun4in6[t].bandwidth+'</li>';
66 }
67 gateways += '</ul>';
68
69 //Adding HNAs with prefix=128 as main address
70 var ipstxt = '';
71 var address;
72 var first = 1;
73 var ipstxt_hidden = '<ul>';
74 var hna6list = '<ul>';
75
76 for( var e = 0; e < hna6.length; e++ )
77 {
78 address = hna6[e].address;
79 prefix = hna6[e].prefixlen;
80 if ( prefix == '128' )
81 {
82 if (first)
83 {
84 ipstxt += address;
85 ipstxt_hidden += '<li><a href="http://['+address+']" >'+address+"</a></li>";
86 first = 0;
87 }
88 else {
89 ipstxt_hidden += '<li><a href="http://['+address+']" >'+address+"</a></li>";
90 }
91 }
92 else {
93 hna6list += '<li>'+address+'/'+prefix+'</li>';
94 }
95 }
96 hna6list += '</ul>';
97 ipstxt_hidden += '</ul>';
98
99 tr.insertCell(-1).innerHTML = ipstxt;
100
101 tr.insertCell(-1).innerHTML = originators[i].viaDev;
102 tr.insertCell(-1).innerHTML = originators[i].metric;
103 tr.insertCell(-1).innerHTML = originators[i].lastDesc;
104 tr.insertCell(-1).innerHTML = originators[i].lastRef;
105 tr.insertCell(-1).innerHTML = originators[i].blocked;
106 //tr.onclick = displayExtraInfo("ip-"+i);
107
108 extrainfo = '<div id="ip-'+ i +'" class="hideme">' + "<div class='inforow'><br /><br /><h4>" + nodename + '</h4></div>\n' + "<div class='inforow'><h5>Available IPs</h5>\n<p>" + ipstxt_hidden + "</p></div>\n" + "<div class='inforow'><h5>Gateways announced</h5>\n<p>" + gateways + "</p></div>\n" + "<div class='inforow'><h5>Networks announced</h5>\n<p>" + hna6list + "</p></div>\n";
109
110 extrainfo += "\n</div>";
111
112 tr.insertCell(-1).innerHTML = extrainfo;
113
114 }
115
116 if( tb.rows.length == 1 )
117 {
118 var tr = tb.insertRow(-1);
119 tr.className = 'cbi-section-table-row';
120
121 var td = tr.insertCell(-1);
122 td.colSpan = 7;
123 td.innerHTML = '<em><br /><%:There are no nodes available.%></em>';
124 }
125 }
126 }
127 );
128 //]]></script>
129
130 <style>
131
132 div.hideme{
133 display: none;
134 }
135
136 div.info{
137 background: #FFF;
138 border: solid 1px;
139 height: 80px;
140 display: block;
141 overflow: auto;
142 text-align: center;
143 }
144
145 div.inforow{
146 text-align:center;
147 display:inline-block;
148 width:20%;
149 margin:5px;
150 vertical-align:top;
151 }
152
153 #extra-info ul { list-style: none outside none; margin-left: 0em; }
154
155 </style>
156 <div class="cbi-map">
157
158 <h2>Originators</h2>
159 <div class="cbi-map-descr"></div>
160 <div id="extra-info" class="info">
161 <br />
162 Click to the icon <img src="<%=resource%>/cbi/help.gif" /> to see individual node information
163 </div>
164 <fieldset class="cbi-section">
165 <legend><%:Mesh nodes%></legend>
166 <table class="cbi-section-table" id="descriptions_table">
167 <tr class="cbi-section-table-titles">
168 <th class="cbi-section-table-cell"></th>
169 <th class="cbi-section-table-cell"><%:Hostname%></th>
170 <th class="cbi-section-table-cell"><%:Primary IP%></th>
171 <th class="cbi-section-table-cell"><%:Via Device%></th>
172 <th class="cbi-section-table-cell"><%:Metric%></th>
173 <th class="cbi-section-table-cell"><%:Last Desc%></th>
174 <th class="cbi-section-table-cell"><%:Last Ref%></th>
175 <th class="cbi-section-table-cell"><%:Blocked%></th>
176 </tr>
177 <tr class="cbi-section-table-row">
178 <td colspan="8"><em><br /><%:Collecting data...%></em></td>
179 </tr>
180 </table>
181 </fieldset>
182
183 </div>
184 <a href="<%=link_non_js%>">Go to non JavaScript view</a>
185
186
187 <%+footer%>
188