summaryrefslogtreecommitdiff
path: root/js/looking-glass.js
blob: b837e82e364e5bb1a6b4e99be2d834e418fb35e1 (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
$(document).ready(function() {
  // hide the optional parameters field
  $('.result').hide();
  $('.loading').hide();

  // show and hide loading bar
  $(document).ajaxStart(function() {
    $('#command_properties').attr('disabled', '');
    $('.loading').show();
  });
  $(document).ajaxStop(function() {
    $('#command_properties').removeAttr('disabled');
    $('.loading').hide();
  });

  // 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);
    });
  });
});