From b5de18337a148017f5d3bfa101ee4cc25f2dee98 Mon Sep 17 00:00:00 2001 From: Guillaume Mazoyer Date: Tue, 5 Aug 2014 14:37:09 +0200 Subject: 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. --- js/looking-glass.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'js') 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(); -- cgit v1.2.3