index.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Vue.js markdown editor example</title>
  6. <link rel="stylesheet" href="css/style.css">
  7. <script src="https://unpkg.com/lodash@4.16.0"></script>
  8. <!-- Delete ".min" for console warnings in development -->
  9. <script src="js/vue.js"></script>
  10. </head>
  11. <body>
  12. <div id="app">
  13. <textarea v-model="input" cols="80" rows="20"></textarea>
  14. <button v-on:click="send">send</button>
  15. </div>
  16. <script type="text/ecmascript">
  17. new Vue({
  18. el: '#app',
  19. data: {
  20. input: '// rde.writeCmd("set_digital_out(2,True)");\n' +
  21. '// rde.writeCmd("movej([-1.95,-1.58,-1.16,-1.15,-1.55,1.25], a=1.0, v=0.1)");\n' +
  22. '//rde.writeCmd("freedrive_mode()");\n'+
  23. 'def asdf():\n' +
  24. ' set_digital_out(3, True) \n' +
  25. ' set_digital_out(4, True) \n' +
  26. 'end',
  27. log: null
  28. },
  29. created: function() {
  30. setTimeout(this.update, 1000);
  31. },
  32. methods: {
  33. send: function (event) {
  34. fetch('/cmd', {method: "POST", body: this.input})
  35. .then(function(response) {
  36. return response;
  37. });
  38. },
  39. update: function (event) {
  40. fetch('/log', {method: "GET"})
  41. .then((value) => {
  42. this.$data.log=value;
  43. })
  44. }
  45. }
  46. })
  47. </script>
  48. </body>
  49. </html>