summaryrefslogtreecommitdiff
path: root/js/looking-glass.js
diff options
context:
space:
mode:
authorGuillaume Mazoyer <respawneral@gmail.com>2014-06-10 14:37:04 +0200
committerGuillaume Mazoyer <respawneral@gmail.com>2014-06-10 14:37:04 +0200
commitd45eab0fe59e5a24e0562365d3c314ca7bde99f3 (patch)
treedfc8175e0e682582aa336da884638b57d1c1da1f /js/looking-glass.js
parent5f29b7aa41a46e2b791c0dfc1023a07b02972e1f (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.js38
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);
+ });
+ });
+});