function renderTableXRoutes(ubus_data, target_div) { var data = ubus_data; for (var protocol in data) { var target = target_div; var title = document.createElement('h3'); title.appendChild(document.createTextNode('X-Routes ' + protocol)); target.appendChild(title); var table = document.createElement('table'); table.setAttribute('class', 'table'); table.setAttribute('id', 'babel_overview_xroutes_' + protocol); var headerRow = document.createElement('tr'); headerRow.setAttribute('class', 'tr table-titles'); var headerContent = '' + '%h'.format(protocol) + ' Prefix\ Metric\ Source-Prefix'; headerRow.innerHTML = headerContent; table.appendChild(headerRow); for (var prefix in data[protocol]) { var prefixRow = document.createElement('tr'); prefixRow.setAttribute('class', 'tr'); var prefixContent = '' + '%h'.format(data[protocol][prefix]["address"]) + '\ ' + '%d'.format(data[protocol][prefix]["metric"]) + '\ ' + '%h'.format(data[protocol][prefix]["src_prefix"]) + ''; prefixRow.innerHTML = prefixContent; table.appendChild(prefixRow); } target.appendChild(table); } } function renderTableRoutes(ubus_data, target_div) { var data = ubus_data; for (var protocol in data) { var target = target_div; var title = document.createElement('h3'); title.appendChild(document.createTextNode('Routes ' + protocol)); target.appendChild(title); var table = document.createElement('table'); table.setAttribute('class', 'table'); table.setAttribute('id', 'babel_overview_routes_' + protocol); var headerRow = document.createElement('tr'); headerRow.setAttribute('class', 'tr table-titles'); var headerContent = '' + '%h'.format(protocol) + ' Prefix\ Source-Prefix\ Route-Metric\ Route Smoothed Metric\ Refmetric\ ID\ Seq. No.\ Age\ Via\ Nexthop\ Installed\ Feasible'; headerRow.innerHTML = headerContent; table.appendChild(headerRow); for (var prefix in data[protocol]) { var prefixRow = document.createElement('tr'); prefixRow.setAttribute('class', 'tr'); var prefixContent = '' + '%h'.format(data[protocol][prefix]["address"]) + '\ ' + '%h'.format(data[protocol][prefix]["src_prefix"]) + '\ ' + '%d'.format(data[protocol][prefix]["route_metric"]) + '\ ' + '%d'.format(data[protocol][prefix]["route_smoothed_metric"]) + '\ ' + '%d'.format(data[protocol][prefix]["refmetric"]) + '\ ' + '%h'.format(data[protocol][prefix]["id"]) + '\ ' + '%d'.format(data[protocol][prefix]["seqno"]) + '\ ' + '%d'.format(data[protocol][prefix]["age"]) + '\ ' + '%h'.format(data[protocol][prefix]["via"]) + '\ ' + '%h'.format(data[protocol][prefix]["nexthop"]) + '\ ' + '%b'.format(data[protocol][prefix]["installed"]) + '\ ' + '%b'.format(data[protocol][prefix]["feasible"]) + ''; prefixRow.innerHTML = prefixContent; table.appendChild(prefixRow); } target.appendChild(table); } } function renderTableNeighbours(ubus_data, target_div) { var data = ubus_data; for (var protocol in data) { var target = target_div; var title = document.createElement('h3'); title.appendChild(document.createTextNode('Neighbours ' + protocol)); target.appendChild(title); var table = document.createElement('table'); table.setAttribute('class', 'table'); table.setAttribute('id', 'babel_overview_neighbours_' + protocol); var headerRow = document.createElement('tr'); headerRow.setAttribute('class', 'tr table-titles'); var headerContent = '' + '%h'.format(protocol) + ' Neighbour\ Device\ Multicast Hellos\ Unicast Hellos\ RX cost\ TX cost\ RTT\ Interface up'; headerRow.innerHTML = headerContent; table.appendChild(headerRow); for (var neighbour in data[protocol]) { var neighbourRow = document.createElement('tr'); neighbourRow.setAttribute('class', 'tr'); var neighbourContent = '' + '%h'.format(data[protocol][neighbour]["address"]) + '\ ' + '%h'.format(data[protocol][neighbour]["dev"]) + '\ ' + '%d'.format(data[protocol][neighbour]["hello_reach"]) + '\ ' + '%d'.format(data[protocol][neighbour]["uhello_reach"]) + '\ ' + '%d'.format(data[protocol][neighbour]["rxcost"]) + '\ ' + '%d'.format(data[protocol][neighbour]["txcost"]) + '\ ' + '%d'.format(data[protocol][neighbour]["rtt"]) + '\ ' + '%b'.format(data[protocol][neighbour]["if_up"]) + ''; neighbourRow.innerHTML = neighbourContent; table.appendChild(neighbourRow); } target.appendChild(table); } } function renderTableInfo(ubus_data, target_div) { var data = ubus_data; var target = target_div; var title = document.createElement('h3'); title.appendChild(document.createTextNode('Info')); target.appendChild(title); var table = document.createElement('table'); table.setAttribute('class', 'table'); table.setAttribute('id', 'babel_overview_info'); var headerRow = document.createElement('tr'); headerRow.setAttribute('class', 'tr table-titles'); var headerContent = 'Babeld Version\ My-ID\ Host'; headerRow.innerHTML = headerContent; table.appendChild(headerRow); var neighbourRow = document.createElement('tr'); neighbourRow.setAttribute('class', 'tr'); var neighbourContent = '' + '%h'.format(data["babeld_version"]) + '\ ' + '%h'.format(data["my_id"]) + '\ ' + '%h'.format(data["host"]) + ''; neighbourRow.innerHTML = neighbourContent; table.appendChild(neighbourRow); target.appendChild(table); }