summaryrefslogtreecommitdiff
path: root/includes/main.js
diff options
context:
space:
mode:
authorGuillaume Mazoyer <respawneral@gmail.com>2014-06-03 10:29:30 +0200
committerGuillaume Mazoyer <respawneral@gmail.com>2014-06-03 10:29:30 +0200
commitae8e479c1a8ae55c5cfbc56788da7954243e5164 (patch)
tree1f1b275790e3ba58a37f8d7fbc8aaadd1f4307d3 /includes/main.js
parent1508b3780dff32ac878d20ebb1d41ebfc27c5909 (diff)
Rename main JS file.
Diffstat (limited to 'includes/main.js')
-rw-r--r--includes/main.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/includes/main.js b/includes/main.js
new file mode 100644
index 0000000..e2b0a6f
--- /dev/null
+++ b/includes/main.js
@@ -0,0 +1,38 @@
+$(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);
+ });
+ });
+});