router.html: Fix MAC addresses in neighbor graph

This adds a JavaScript function for integer to MAC address
conversion.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2019-05-12 14:17:00 +02:00
parent 15c6c6062f
commit ca7c2ff3b3
3 changed files with 10 additions and 1 deletions

View File

@ -105,10 +105,12 @@ function neighbour_graph(neigh_label) {
for (var j in neigh_stats) {
var dataset = neigh_stats[j];
var label = j;
var label;
var data = [];
if(j in neigh_label) {
label = neigh_label[j];
} else {
label = int2mac(j);
}
for (len=dataset.length, i=0; i<len; i++) {
try {

View File

@ -0,0 +1,6 @@
function int2mac(input) {
return ("000000000000" + parseInt(input).toString(16)).substr(-12) // make HEX and add leading zeros
.match( /.{1,2}/g ) // ["4a", "89", "26", "c4", "45", "78"]
.join( ':' ) // "78:45:c4:26:89:4a"
}

View File

@ -11,6 +11,7 @@
<script src="{{ url_for('static', filename='js/graph/jquery.flot.downsample.js') }}"></script>
<script src="{{ url_for('static', filename='js/graph/jquery.flot.resize.js') }}"></script>
<script src="{{ url_for('static', filename='js/graph/jquery.flot.hiddengraphs.js') }}"></script>
<script src="{{ url_for('static', filename='js/util.js') }}"></script>
<script src="{{ url_for('static', filename='js/graph.js') }}"></script>
<style type="text/css">
#map {