Add js/dynamic boxes webpage.

Much better code. Uses ranking code to create json blob with
series data.
master
Auke Kok 2017-11-13 01:35:59 +00:00
parent c5614b804e
commit ed5c99b723
3 changed files with 59 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
boxes.html
mt-lag-30d.png
mt-lag.png
mt-players-30d.png

16
boxes.html Normal file
View File

@ -0,0 +1,16 @@
<html>
<head>
<title>Boxes</title>
<link rel="stylesheet" href="css/beauty.min.css" />
</head>
<body>
<script src="nav.js"></script>
<h1>Boxes!</h1>
<div id="series"></div>
<script src="series.js"></script>
<script src="bot.js"></script>
</body>
</html>

43
series.js Normal file
View File

@ -0,0 +1,43 @@
String.prototype.capitolize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
function jsonget(url)
{
var r = new XMLHttpRequest();
r.open("GET", url, true);
r.setRequestHeader("Content-type", "application/json")
r.onreadystatechange = function()
{
if (r.readyState == 4 && r.status == 200)
{
var tbl = JSON.parse(r.responseText);
var s = "";
Object.keys(tbl).forEach(function(key, index) {
var series = tbl[key];
s += "<h2>" + series.name.capitolize() + " series</h2>\n";
s += "<table style=\"width: 80%;margin: 0 auto;\">\n";
s += "<th width=\"5%\"></th><th width=\"15%\">Number</th><th width=\"60%\">Name</th><th>Builder</th>\n";
var boxes = series.boxes;
Object.keys(boxes).forEach(function(key2, index2) {
s += "<tr>";
s += "<td>" + index2 + "</td>";
s += "<td>" + boxes[key2].id + "</td>";
s += "<td>" + boxes[key2].name + "</td>";
s += "<td>" + boxes[key2].builder + "</td>";
s += "</tr>\n";
})
s += "</table>\n\n";
})
document.getElementById("series").innerHTML = s;
}
}
r.send();
}
jsonget("http://minetest.foo-projects.org/series.json");