12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <!DOCTYPE html>
- <html>
- <head>
- <!-- Standard Meta -->
- <meta charset="utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
- <!-- Site Properties -->
- <title>Minecraft Server</title>
- <script src="https://code.jquery.com/jquery-3.1.1.min.js" crossorigin="anonymous"></script>
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
- <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
- </head>
- <body>
- <div class="ui form">
- <div class="field">
- <textarea id="log" rows="30"></textarea>
- </div>
- </div>
- <br>
- <div class="ui fluid action input">
- <input type="text" id="command" placeholder="Command here (e.g. give @a minecraft:wooden_axe)">
- <div class="ui button" onclick="sendCmd()">Send</div>
- </div>
- </body>
- <script>
- var currentLogID = 0;
- function refreshLog() {
- $.get("log/from?start=" + currentLogID, function(data) {
- $.each(data, function(index, value) {
- $("#log").append(value.Log + "\n");
- currentLogID = value.ID + 1;
- });
- $('#log').scrollTop($('#log')[0].scrollHeight);
- });
- }
- setInterval(function() {
- refreshLog()
- }, 3000);
- function sendCmd() {
- var cmdVal = $("#command").val();
- $.get("sendcommand?command=" + cmdVal, function(data) {
- $("#log").append("Command: [" + cmdVal + "] sent\n");
- $("#command").val("");
- //increase the refresh speed immd after sending command
- setTimeout(refreshLog, 1000);
- });
- }
- $('#command').on("keypress", function(e) {
- if (e.keyCode == 13) {
- sendCmd();
- return false; // prevent the button click from happening
- }
- });
- </script>
- </html>
|