-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdomains.js.tmpl
41 lines (36 loc) · 1.41 KB
/
domains.js.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<script>
$("#domain-table").bootstrapTable();
// https://stackoverflow.com/a/21903119
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
function update() {
var stats_url = "http://" + controller_addr + "/get_statistics";
$.ajax({
url: stats_url,
dataType: "json",
success: function(data) {
$("#error-msg").removeClass("show");
var domains = [];
$.each(data["domains"], function (idx, ds) {
domains.push([idx, Object.keys(ds[1]).length, ds[0]["total_forward_time"], ds[0]["total_replay_time"], ds[0]["wait_time"]]);
});
$("#domain-table").bootstrapTable('load', domains);
},
error: function(e) {
$("#error-msg").html("AJAX request to controller API failed: " + e.statusText).addClass("show");
}
});
}
update();
setInterval(update, 1000);
</script>