Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 1 | function prefix() |
| 2 | { |
| 3 | var tmp = document.getElementById("prefixcontent").innerHTML; |
| 4 | var data = tmp.split("END"); |
| 5 | var odd = "odd"; |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 6 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 7 | for (var i in data) { |
| 8 | // Parse the JSON data. |
| 9 | var obj = jQuery.parseJSON(data[i]); |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 10 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 11 | if (i % 2 == 0) { |
| 12 | odd = ""; |
| 13 | } |
| 14 | else { |
| 15 | odd = "odd"; |
| 16 | } |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 17 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 18 | // Create the HTML for each prefix. |
| 19 | var output = '<tr class="' + odd + '">\n'; |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 20 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 21 | output += |
| 22 | '<td rowspan="' + obj.prefixes.length + '">' + obj.router + '</td>'; |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 23 | |
| 24 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 25 | for (var i in obj.prefixes) { |
| 26 | output += '<td class="' + odd + '">' + obj.prefixes[i].timestamp + '</td>'; |
| 27 | output += '<td class="' + odd + '">' + obj.prefixes[i].prefix + '</td>'; |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 28 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 29 | if (obj.prefixes[i].status == "notintopology") { |
| 30 | output += '<td id="' + obj.prefixes[i].status + '">NPT</td>'; |
| 31 | } |
| 32 | else { |
| 33 | output += '<td id="' + obj.prefixes[i].status + '">' + |
| 34 | obj.prefixes[i].status + '</td>'; |
| 35 | } |
| 36 | |
| 37 | output += '</tr>'; |
| 38 | } |
| 39 | |
| 40 | // Append the data to the prefix table. |
| 41 | $('.one > tbody:last').append(output); |
| 42 | } |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 43 | } |
| 44 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 45 | function link() |
| 46 | { |
| 47 | var tmp = document.getElementById("linkcontent").innerHTML; |
| 48 | var data = tmp.split("END"); |
| 49 | var odd = "odd"; |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 50 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 51 | for (var i in data) { |
| 52 | // Parse the JSON data. |
| 53 | var obj = jQuery.parseJSON(data[i]); |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 54 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 55 | if (i % 2 == 0) { |
| 56 | odd = ""; |
| 57 | } |
| 58 | else { |
| 59 | odd = "odd"; |
| 60 | } |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 61 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 62 | // Create the HTML for each prefix. |
| 63 | var output = '<tr class="' + odd + '">\n'; |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 64 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 65 | output += '<td rowspan="' + obj.links.length + '">' + obj.router + '</td>'; |
| 66 | output += |
| 67 | '<td rowspan="' + obj.links.length + '">' + obj.timestamp + '</td>'; |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 68 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 69 | for (var i in obj.links) { |
| 70 | output += |
| 71 | '<td id="' + obj.links[i].status + '">' + obj.links[i].link + '</td>'; |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 72 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 73 | if (obj.links[i].status == "notintopology") { |
| 74 | output += '<td id="' + obj.links[i].status + '">NPT</td>'; |
| 75 | } |
| 76 | else { |
| 77 | output += '<td id="' + obj.links[i].status + '">' + |
| 78 | obj.links[i].status + '</td>'; |
| 79 | } |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 80 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 81 | output += '</tr>'; |
| 82 | } |
| 83 | |
| 84 | // Append the data to the prefix table. |
| 85 | $('.two > tbody:last').append(output); |
| 86 | } |
Zhenkai Zhu | 5c2475b | 2013-02-26 22:57:31 -0800 | [diff] [blame] | 87 | } |