Advertisement
maygapixel

Untitled

Apr 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends layout
  2.  
  3. block content
  4.     div.page-content
  5.         div.content-wrapper
  6.             div
  7.                 div.col-md-6
  8.                     div.panel.panel-flat
  9.                         div.panel-heading
  10.                             h6.panel-title Move
  11.                             div.heading-elements
  12.                                 div.heading-btn.btn-group
  13.                                     button.btn.btn-xs.btn-danger(type="button") E-Stop
  14.                                     button.btn.btn-xs.btn-warning(type="button", id="soft-reset") Soft-Reset
  15.                         div.container-fluid
  16.                             label.text-center MOVE AMOUNT (mm)
  17.                             div.move-amount-wrapper
  18.                                 button.move-amount.no-radius.fb-button.leftmost 1
  19.                                 button.move-amount.no-radius.fb-button.move-amount-selected 10
  20.                                 button.move-amount.no-radius.fb-button.leftmost 100
  21.                                 button.move-amount.no-radius.fb-button.leftmost 1000
  22.                                 button.move-amount.no-radius.fb-button.leftmost 10000
  23.                             table.jog-table(style="border: 0px none;")
  24.                                 tbody
  25.                                     tr
  26.                                         td
  27.                                             //-button.i.fa.fa-camera.arrow-button.fb-button
  28.                                         td
  29.                                         td
  30.                                         td
  31.                                             button.fb-button.fa.fa-2x.arrow-button.radius.fa-arrow-up(title="move y axis", id="yup")
  32.                                         td
  33.                                         td
  34.                                         td
  35.                                             button.fb-button.fa.fa-2x.arrow-button.radius.fa-arrow-up(title="move z axis", id="zup")
  36.                                     tr
  37.                                         td
  38.                                             button.i.fa.fa-home.arrow-button.fb-button(id="home")
  39.                                         td
  40.                                         td
  41.                                             button.fb-button.fa.fa-2x.arrow-button.radius.fa-arrow-left(title="move x axis", id="xdown")
  42.                                         td
  43.                                             button.fb-button.fa.fa-2x.arrow-button.radius.fa-arrow-down(title="move y axis", id="ydown")
  44.                                         td
  45.                                             button.fb-button.fa.fa-2x.arrow-button.radius.fa-arrow-right(title="move x axis", id="xup")
  46.                                         td
  47.                                         td
  48.                                             button.fb-button.fa.fa-2x.arrow-button.radius.fa-arrow-down(title="move z axis", id="zdown")
  49.                                     tr
  50.                                         td
  51.  
  52.                             div.row
  53.                                 div.col-xs-3
  54.                                     label X AXIS
  55.                                 div.col-xs-3
  56.                                     label Y AXIS
  57.                                 div.col-xs-3
  58.                                     label Z AXIS
  59.                             div.row
  60.                                 div.col-xs-3
  61.                                     input.form-control(id="current_x", type="number", disabled="", value=0)
  62.                                 div.col-xs-3
  63.                                     input.form-control(id="current_y", type="number", disabled="", value=0)
  64.                                 div.col-xs-3
  65.                                     input.form-control(id="current_z", type="number", disabled="", value=0)
  66.                                 div.col-xs-3
  67.                                     label Motor Coordinates (mm)
  68.                             div.row
  69.                                 div.col-xs-3
  70.                                     input.form-control(type="number", value="")
  71.                                 div.col-xs-3
  72.                                     input.form-control(type="number", value="")
  73.                                 div.col-xs-3
  74.                                     input.form-control(type="number", value="")
  75.                                 div.col-xs-3
  76.                                     button.full-width.green.go.fb-button GO
  77.                             div.row
  78.                                 div.col-md-12
  79.                                     textarea.form-control(id='console', readonly='readonly', rows='7')
  80.  
  81.                 div.col-md-6
  82.                     div.panel.panel-flat
  83.                         div.panel-heading
  84.                             h6.panel-title Webcam Feeds
  85.                         div.container-fluid
  86.                             div.image-flipper
  87.                                 div
  88.                                     img(style="-webkit-user-select: none;",src=motion_url)
  89.                                 div.no-flipper-image-container
  90.                                 button.image-flipper-left.fb-button(hidden="") Prev
  91.                                 button.image-flipper-right.fb-button(hidden="") Next
  92.  
  93.     script.
  94.         //$( document ).ready(function() {
  95.             var socket = io();
  96.             var psconsole = $('#console');
  97.            
  98.             socket.on('response', function (data) {  
  99.                 $('#current_x').val(data.current_x);
  100.                 $('#current_y').val(data.current_y);
  101.                 $('#current_z').val(data.current_z);
  102.                 $('#console').append('>>> '+data.log);
  103.  
  104.                 if(psconsole.length) {
  105.                     psconsole.scrollTop(psconsole[0].scrollHeight - psconsole.height());
  106.                 }
  107.             });
  108.            
  109.  
  110.             console.log('ready!');
  111.  
  112.             $('#home').click(function(e) {
  113.                 execute('home');
  114.             });
  115.             $('#xup').click(function(e) {
  116.                 execute('xup');
  117.                 //console.log('move: x-up');
  118.             });
  119.  
  120.             $('#xdown').click(function(e) {
  121.                 execute('xdown');
  122.                 //console.log('move: x-down');
  123.             });
  124.  
  125.             $('#yup').click(function(e) {
  126.                 execute('yup');
  127.             });
  128.  
  129.             $('#ydown').click(function(e) {
  130.                 execute('ydown');
  131.             });
  132.  
  133.             $('#zup').click(function(e) {
  134.                 execute('zup');
  135.             });
  136.  
  137.             $('#zdown').click(function(e) {
  138.                 execute('zdown');
  139.             });
  140.  
  141.             $('#soft-reset').click(function(e) {
  142.                 execute('soft-reset');
  143.             });
  144.  
  145.             function execute(action) {
  146.                 $.ajax({
  147.                     url: "./api/controls/move",
  148.                     method: 'post',
  149.                     data: {action: action}
  150.                     }).done(function(res) {
  151.                         //console.log(res.msg);
  152.                     });
  153.             }
  154.  
  155.             // WASD and up/down keys
  156.             $(document).keydown(function (e) {
  157.                 var keyCode = e.keyCode || e.which;
  158.  
  159.                 if ($('#command').is(':focus')) {
  160.                     // don't handle keycodes inside command window
  161.                     return;
  162.                 }
  163.  
  164.                 switch (keyCode) {
  165.                 case 65:
  166.                     // a key X-
  167.                     e.preventDefault();
  168.                     $('#xdown').click();
  169.                     break;
  170.                 case 68:
  171.                     // d key X+
  172.                     e.preventDefault();
  173.                     $('#xup').click();
  174.                     break;
  175.                 case 87:
  176.                     // w key Y+
  177.                     e.preventDefault();
  178.                     $('#yup').click();
  179.                     break;
  180.                 case 83:
  181.                     // s key Y-
  182.                     e.preventDefault();
  183.                     $('#ydown').click();
  184.                     break;
  185.                 case 38:
  186.                     // up arrow Z+
  187.                     e.preventDefault();
  188.                     $('#zup').click();
  189.                     break;
  190.                 case 40:
  191.                     // down arrow Z-
  192.                     e.preventDefault();
  193.                     $('#zdown').click();
  194.                     break;
  195.                 }
  196.             });
  197.  
  198.         //});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement