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(prefix) + '\ ' + '%h'.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.\ Channes\ 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(prefix) + '\ ' + '%h'.format(data[protocol][prefix]["src-prefix"]) + '\ ' + '%h'.format(data[protocol][prefix]["route_metric"]) + '\ ' + '%h'.format(data[protocol][prefix]["route_smoothed_metric"]) + '\ ' + '%h'.format(data[protocol][prefix]["refmetric"]) + '\ ' + '%h'.format(data[protocol][prefix]["id"]) + '\ ' + '%h'.format(data[protocol][prefix]["seqno"]) + '\ ' + '%h'.format(data[protocol][prefix]["channels"]) + '\ ' + '%h'.format(data[protocol][prefix]["age"]) + '\ ' + '%h'.format(data[protocol][prefix]["via"]) + '\ ' + '%h'.format(data[protocol][prefix]["nexthop"]) + '\ ' + '%h'.format(data[protocol][prefix]["installed"]) + '\ ' + '%h'.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\ Hello-Reach\ RX cost\ TX cost\ RTT\ Channel\ 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(neighbour) + '\ ' + '%h'.format(data[protocol][neighbour]["dev"]) + '\ ' + '%h'.format(data[protocol][neighbour]["hello-reach"]) + '\ ' + '%h'.format(data[protocol][neighbour]["rxcost"]) + '\ ' + '%h'.format(data[protocol][neighbour]["txcost"]) + '\ ' + '%h'.format(data[protocol][neighbour]["rtt"]) + '\ ' + '%h'.format(data[protocol][neighbour]["channel"]) + '\ ' + '%h'.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); }