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