summaryrefslogtreecommitdiff
path: root/includes/utils.js
blob: 3bcde519ab81f3e10518a8e9c38d04214408a9c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
$(function() {
  // hide the optional parameters field
  $('.result').hide();
  $('.loading').hide();

  // show and hide loading bar
  $(document).ajaxStart(function() {
    $('.loading').show();
  });
  $(document).ajaxStop(function() {
    $('.loading').hide();
  });

  // validate the parameters field
  $('#input-params').on('input', function() {
    var cmd = $('#query').val();
  });

  // reset the view to the default one
  $('#backhome').click(function() {
    $('.content').slideDown();
    $('.result').slideUp();
  });

  // send an ajax request that will get the info on the router
  $('form').on('submit', function(e) {
    e.preventDefault();

    $.ajax({
      type: 'post',
      url: 'execute.php',
      data: $('form').serialize()
    }).done(function(response, state, xhr) {
      $('#output').text(response);
      $('.content').slideUp();
      $('.result').slideDown();
    }).fail(function(xhr, state, error) {
      alert('The following error occured: ' + state, error);
    });
  });
});