ui.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <script src="https://code.jquery.com/jquery-3.3.1.min.js"
  6. integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  7. crossorigin="anonymous"></script>
  8. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocas-ui/2.3.3/tocas.css">
  9. <script src="https://cdnjs.cloudflare.com/ajax/libs/tocas-ui/2.3.3/tocas.js"></script>
  10. <title>Cloud Slicer UI</title>
  11. <script src="upld.js"></script>
  12. <script src="stl_viewer.min.js"></script>
  13. <style>
  14. #stl_cont{
  15. width:100%;
  16. min-height:500px;
  17. }
  18. #gcodePreview{
  19. width:100%;
  20. min-height:500px;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <br><br>
  26. <div class="ts container">
  27. <div class="ts segment">
  28. <div class="ts header">
  29. <i class="cloud icon"></i> 3D 打印機集群雲端切片界面 (測試版)
  30. <div class="sub header">對,即使是 ESP8266 也能直接打印 STL</div>
  31. </div>
  32. <div class="ts steps">
  33. <div class="active step">
  34. <i class="cloud upload icon"></i>
  35. <div class="content">
  36. <div class="title">上載 STL 檔</div>
  37. <div class="description">最大限制 256MB</div>
  38. </div>
  39. </div>
  40. <div class="step">
  41. <i class="wait icon"></i>
  42. <div class="content">
  43. <div class="title">等待切片</div>
  44. <div class="description">應該不會等得久,因為雲端已經幫你做了大部分的運算</div>
  45. </div>
  46. </div>
  47. <div class="step">
  48. <i class="print icon"></i>
  49. <div class="content">
  50. <div class="title">開始打印</div>
  51. <div class="description">現在就到你的 ESP8266 開始工作了</div>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="ts segment">
  57. <form id="fileform" enctype="multipart/form-data">
  58. <input type="file" name="file" id="modelfile">
  59. </form>
  60. <button class="ts basic button" onClick="uploadFile();">上載並預覽</button>
  61. </div>
  62. <div id="previewWindow" class="ts segment">
  63. <div id="stl_cont"></div>
  64. <p></p>
  65. </div>
  66. <div class="ts segment">
  67. <button class="ts basic button" onClick="slice();">切片並取得 Gcode</button>
  68. <textarea id="gcodePreview">
  69. </textarea>
  70. </div>
  71. <div class="ts segment">
  72. <button class="ts basic button" onClick="sendToESP();">傳送至 ESP8266 並打印</button>
  73. </div>
  74. <br><br><br><br>
  75. </div>
  76. <script>
  77. var cloudServerAddress = "http://" + window.location.host + "/CURA/"; //Replace this with your cloud slicer URL
  78. var filename = "";
  79. var gcodeFilename = "";
  80. function previewStl(filename){
  81. var stl_viewer = new StlViewer(document.getElementById("stl_cont"), { models: [ {id:0, filename: cloudServerAddress + "input/" + filename} ] });
  82. $("#previewWindow").find("p").text(filename);
  83. }
  84. function sendToESP(){
  85. alert("This is implemented by the developer");
  86. }
  87. function slice(){
  88. if (filename != ""){
  89. $.get(cloudServerAddress + "slice.php?inputfile=" + filename,function(data){
  90. gcodeFilename = data;
  91. previewGcode(gcodeFilename);
  92. });
  93. }else{
  94. alert("Please upload a file and press preview before slicing");
  95. }
  96. }
  97. function previewGcode(filename){
  98. $.get(cloudServerAddress + "output/" + filename,function(data){
  99. $("#gcodePreview").val(data);
  100. });
  101. }
  102. function uploadFile(){
  103. $('#modelfile').simpleUpload(cloudServerAddress + "upload.php",{
  104. start: function(file){
  105. //upload started
  106. console.log(file);
  107. },
  108. progress: function(progress){
  109. //received progress
  110. },
  111. success: function(data){
  112. //upload successful
  113. console.log(data);
  114. filename = data;
  115. //filename example: 1553943731.stl (which is PHP time stamp)
  116. previewStl(data);
  117. },
  118. error: function(error){
  119. //upload failed
  120. }
  121. });
  122. }
  123. </script>
  124. </body>
  125. </html>