index.html 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <!-- Standard Meta -->
  5. <meta charset="utf-8" />
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  8. <!-- Site Properties -->
  9. <title>Octave</title>
  10. <script src="https://code.jquery.com/jquery-3.1.1.min.js" crossorigin="anonymous"></script>
  11. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
  12. <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
  13. </head>
  14. <body>
  15. <div class="ui form">
  16. <div class="field">
  17. <div id="log" contenteditable="true" style="white-space: pre;overflow-x: scroll;font-family: monospace;"></div>
  18. </div>
  19. </div>
  20. <br>
  21. <div class="ui fluid action input">
  22. <input type="text" id="command" placeholder="Command here (e.g. give @a minecraft:wooden_axe)">
  23. <div class="ui button" onclick="sendCmd()">Send</div>
  24. </div>
  25. </body>
  26. <script>
  27. var currentLogID = 0;
  28. var loading = false;
  29. //to fix the fucking log textbox size.
  30. $("#log").height(window.innerHeight - $("#command").height() - 50)
  31. $(window).on('resize', function() {
  32. $("#log").height(window.innerHeight - $("#command").height() - 50)
  33. });
  34. refreshLog();
  35. setInterval(function() {
  36. refreshLog()
  37. }, 1000);
  38. function refreshLog() {
  39. if (!loading) {
  40. loading = true;
  41. $.get("log/from?start=" + currentLogID, function(data) {
  42. previd = currentLogID;
  43. $.each(data, function(index, value) {
  44. $("#log").append(value.Log + "<br>");
  45. currentLogID = value.ID + 1;
  46. });
  47. var data = $("#log").val().split("\n");
  48. if (data.length > 3001) {
  49. $("#log").val("---Log timmeed---\n");
  50. data = data.splice(data.length - 2000, data.length - 1);
  51. $("#log").val(data.join("\n"));
  52. }
  53. loading = false;
  54. });
  55. }
  56. }
  57. function sendCmd() {
  58. var cmdVal = $("#command").val();
  59. $.get("sendcommand?command=" + cmdVal);
  60. $("#log").append("Command: [" + cmdVal + "] sent\n");
  61. $("#command").val("");
  62. }
  63. $('#command').on("keypress", function(e) {
  64. if (e.keyCode == 13) {
  65. sendCmd();
  66. //$("#command").val("");
  67. return false; // prevent the button click from happening
  68. }
  69. });
  70. </script>
  71. </html>