Add Tablefill

This commit is contained in:
VegaZ
2018-10-03 20:36:18 +02:00
parent e900499893
commit 60688d2178
2 changed files with 27 additions and 7 deletions

View File

@@ -13,6 +13,7 @@
<body> <body>
<div class="playerlist"> <div class="playerlist">
<div id="testDiv"></div>
<table> <table>
<thead> <thead>
<tr> <tr>
@@ -21,11 +22,19 @@
<th><center>Ping</center></th> <th><center>Ping</center></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody id="playerData"></tbody>
</tbody>
<tr class="playerAmount"></tr>
</table> </table>
</div> </div>
<script src="jquery-3.3.1.min.js"></script> <script src="jquery-3.3.1.min.js"></script>
<script>
$(document).ready(function () {
//var table;
for (var player in pList) {
$("#playerData").append("<tr><td>" + player.Id + "</td><td>" + player.Name + "</td><td>" + player.Ping + "</td></tr>");
//table =+ tableRow;
}
//document.getElementById("testDiv").innerHTML = table;
});
</script>
</body> </body>
</html> </html>

View File

@@ -16,8 +16,19 @@ mp.events.add("showPlayerlist", () => {
}); });
mp.events.add("fetchPlayerList", (playersJson) => { mp.events.add("fetchPlayerList", (playersJson) => {
var players = JSON.parse(playersJson);
players.forEach((player) => { pList = JSON.parse(playersJson);
pList.forEach((player) => {
mp.gui.chat.push(player.Id + ", " + player.Name + ", " + player.Ping); mp.gui.chat.push(player.Id + ", " + player.Name + ", " + player.Ping);
}); });
}); });
//function getTable() {
// var table = "";
// pList.forEach((player) => {
// var tableRow = "<tr><td>" + player.Id + "</td><td>" + player.Name + "</td><td>" + player.Ping + "</td>";
// table = table + tableRow;
// })
// return document.write(table);
//}