// get all slaves recently connected to master // ask master for slaves setInterval(function() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { var slaveData = JSON.parse(xmlhttp.responseText); var HTML = "

Current connections:

" for(i=0;i

Last seen: "+seenDate+"

Port: "+slaveData[key].serverPort+"

Host: "+slaveData[key].mac+"

" } } document.querySelector("#slaves > #display").innerHTML = HTML } } xmlhttp.open("GET", "slaves", true); xmlhttp.send(); }, 500) function makeGraph(slaveID, selector) { post("http://localhost:8080/getStats", {slaveID: slaveID}, function(data){ console.log(data); }) } // production info // string, object, function(object) function post(url, data, callback) { console.log("POST " + url + JSON.stringify(data)) var xhr = new XMLHttpRequest(); xhr.open("POST", url, true); xhr.setRequestHeader("Content-type", "application/json"); xhr.onreadystatechange = function () { console.log(xhr.readyState + "WOW") if (xhr.readyState == 4 && xhr.status == 200) { var json = JSON.parse(xhr.responseText); callback(json); } } xhr.send(JSON.stringify(data)); }