mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 16:23:12 +09:00
Added webpage to display network contents
This commit is contained in:
1 parent
8ea74821b4
commit
410b3e5e53
4 files changed
+97
-8
No files matched your search
@@ -0,0 +1,27 @@
|
||||
|
||||
|
||||
contents = {
|
||||
"iron-plate":100,
|
||||
"copper-plate":7312,
|
||||
}
|
||||
|
||||
function drawcontents(data) {
|
||||
keys = Object.keys(data);
|
||||
result = "<table>";
|
||||
for(i = 0;i < data.length; i++) {
|
||||
result = result + "<tr><td>" + data[i].name + "</td><td>" + data[i].count + "</td></tr>";
|
||||
}
|
||||
result = result + "</table>"
|
||||
document.getElementById("contents").innerHTML = result;
|
||||
}
|
||||
setInterval(function() {
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
data = JSON.parse(xmlhttp.responseText);
|
||||
drawcontents(data);
|
||||
}
|
||||
}
|
||||
xmlhttp.open("GET", "inventory", true);
|
||||
xmlhttp.send();
|
||||
}, 500)
|
||||
Reference in new issue
Block a user