12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Vue.js markdown editor example</title>
- <link rel="stylesheet" href="css/style.css">
- <script src="https://unpkg.com/lodash@4.16.0"></script>
- <!-- Delete ".min" for console warnings in development -->
- <script src="js/vue.js"></script>
- </head>
- <body>
- <div id="app">
- <textarea v-model="input" cols="80" rows="20"></textarea>
- <button v-on:click="send">send</button>
- <ul id="loglist">
- <li v-for="(item, index) in log.slice().reverse()">
- {{ index }} - {{ item.entry.message }}
- </li>
- </ul>
- </div>
- <script type="application/javascript">
- new Vue({
- el: '#app',
- data: {
- input: '// rde.writeCmd("set_digital_out(2,True)");\n' +
- '// rde.writeCmd("movej([-1.95,-1.58,-1.16,-1.15,-1.55,1.25], a=1.0, v=0.1)");\n' +
- '//rde.writeCmd("freedrive_mode()");\n'+
- 'def asdf():\n' +
- ' set_digital_out(3, True) \n' +
- ' set_digital_out(4, True) \n' +
- 'end',
- log: [],
- lastID: -1
- },
- created: function() {
- setInterval(this.update, 200);
- },
- methods: {
- send: function (event) {
- fetch('/cmd', {method: "POST", body: this.input})
- .then(function(response) {
- return response;
- });
- },
- update: function (event) {
- fetch('/log/'+this.lastID, {method: "GET"})
- .then((response) => {
- return response.json();
- })
- .then((myJson) => {
- console.log(JSON.stringify(myJson));
- this.$data.log=this.$data.log.concat(myJson.entries);
- this.$data.lastID=myJson.lastID;
- });
- }
- }
- })
- </script>
- </body>
- </html>
|