diff options
author | Guillaume Mazoyer <respawneral@gmail.com> | 2014-08-05 14:37:09 +0200 |
---|---|---|
committer | Guillaume Mazoyer <respawneral@gmail.com> | 2014-08-05 14:37:09 +0200 |
commit | b5de18337a148017f5d3bfa101ee4cc25f2dee98 (patch) | |
tree | a39a1afac6821ffc93925dc92d7f3814a2de4a66 /js | |
parent | b5b262d957f1ed42b0252952cb1d5c74d49a49bb (diff) |
Add help button.
Add a help button to the parameter field to get more information
about the selected command and especially about the parameter needed
for the command to be properly executed.
The help appears in a modal dialog whose content is updated when a
command is selected.
Diffstat (limited to 'js')
-rw-r--r-- | js/looking-glass.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/js/looking-glass.js b/js/looking-glass.js index d510ca0..ec26416 100644 --- a/js/looking-glass.js +++ b/js/looking-glass.js @@ -1,3 +1,18 @@ +function request_doc(query) { + $.ajax({ + type: 'post', + url: 'execute.php', + data: { doc: query, dontlook: '' } + }).done(function(response) { + var response = $.parseJSON(response); + + $('#command-help').html(response.query); + $('#parameter-help').html(response.parameter); + }).fail(function(xhr) { + $('#help-content').text('Cannot load documentation...'); + }); +} + $(document).ready(function() { // hide the optional parameters field $('.result').hide(); @@ -18,6 +33,15 @@ $(document).ready(function() { $('.result').slideUp(); }); + // initialize the help modal + request_doc($('#query').val()); + + // update help when a command is selected + $('#query').on('change', function(e) { + e.preventDefault(); + request_doc($('#query').val()); + }); + // send an ajax request that will get the info on the router $('form').on('submit', function(e) { e.preventDefault(); |