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

@@ -8,11 +8,12 @@
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css" />
<script src="playerlist.js"></script>
<script src="playerlist.js"></script>
</head>
<body>
<div class="playerlist">
<div id="testDiv"></div>
<table>
<thead>
<tr>
@@ -21,11 +22,19 @@
<th><center>Ping</center></th>
</tr>
</thead>
<tbody>
</tbody>
<tr class="playerAmount"></tr>
<tbody id="playerData"></tbody>
</table>
</div>
<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>
</html>

View File

@@ -16,8 +16,19 @@ mp.events.add("showPlayerlist", () => {
});
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);
});
});
});
//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);
//}