properties.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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>Minecraft Server</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. <!-- MC Skin-->
  14. <link rel="stylesheet" href="/css/minecraft-skinviewer.css">
  15. <!-- Semantic UI Alert-->
  16. <link rel="stylesheet" href="/css/Semantic-UI-Alert.css">
  17. <script src="/js/semantic-ui-alert.js"></script>
  18. <script src="/js/alert.js"></script>
  19. </head>
  20. <body>
  21. <div id="settings" class="ui form">
  22. </div>
  23. <div class="ui button" onclick="submit()">Update</div>
  24. <div style="height:30px"></div>
  25. </body>
  26. <script>
  27. updateInfo()
  28. function updateInfo() {
  29. $.get("/properties", function(data) {
  30. if (data.length == 0) {
  31. $("#settings").html(`
  32. <div class="inline field">
  33. <label>No item :(</label>
  34. </div>
  35. <div class="ui divider"></div>
  36. `)
  37. return
  38. }
  39. $("#settings").html("");
  40. $.each(data, function(i, item) {
  41. $("#settings").append(`
  42. <div class="inline field">
  43. <label style="width:46vw">` + item.key + `</label>
  44. <input style="width:46vw" type="text" id="` + item.key + `" placeholder="` + item.value + `" value="` + item.value + `">
  45. </div>
  46. <div class="ui divider"></div>
  47. `)
  48. })
  49. });
  50. }
  51. function submit() {
  52. $.each($("input"), function(i, item) {
  53. var key = $(item).attr("id");
  54. var value = $(item).val();
  55. $.get("/properties/change?key=" + key + "&value=" + value, function(data) {
  56. if (data == "OK") {
  57. if (i == $("input").length - 1) {
  58. msgbox("Action completed.");
  59. }
  60. } else {
  61. errmsg(item + ":" + data);
  62. }
  63. updateInfo();
  64. });
  65. })
  66. }
  67. </script>
  68. </html>