diff options
author | Guillaume Mazoyer <respawneral@gmail.com> | 2014-06-10 14:37:04 +0200 |
---|---|---|
committer | Guillaume Mazoyer <respawneral@gmail.com> | 2014-06-10 14:37:04 +0200 |
commit | d45eab0fe59e5a24e0562365d3c314ca7bde99f3 (patch) | |
tree | dfc8175e0e682582aa336da884638b57d1c1da1f /js/looking-glass.js | |
parent | 5f29b7aa41a46e2b791c0dfc1023a07b02972e1f (diff) |
New directory js/ for Javascript file.
Use a local jquery instead of an online one.
Diffstat (limited to 'js/looking-glass.js')
-rw-r--r-- | js/looking-glass.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/js/looking-glass.js b/js/looking-glass.js new file mode 100644 index 0000000..b837e82 --- /dev/null +++ b/js/looking-glass.js @@ -0,0 +1,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); + }); + }); +}); |