summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/looking-glass.js30
1 files changed, 24 insertions, 6 deletions
diff --git a/js/looking-glass.js b/js/looking-glass.js
index b837e82..3a72f23 100644
--- a/js/looking-glass.js
+++ b/js/looking-glass.js
@@ -2,10 +2,12 @@ $(document).ready(function() {
// hide the optional parameters field
$('.result').hide();
$('.loading').hide();
+ $('.alert').hide();
// show and hide loading bar
$(document).ajaxStart(function() {
$('#command_properties').attr('disabled', '');
+ $('.alert').hide();
$('.loading').show();
});
$(document).ajaxStop(function() {
@@ -13,6 +15,14 @@ $(document).ready(function() {
$('.loading').hide();
});
+ // close the alert bar
+ $('.close').click(function() {
+ $('.alert').slideUp();
+ });
+ $('#clear').click(function() {
+ $('.alert').slideUp();
+ });
+
// reset the view to the default one
$('#backhome').click(function() {
$('.content').slideDown();
@@ -27,12 +37,20 @@ $(document).ready(function() {
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);
+ }).done(function(response) {
+ var response = $.parseJSON(response);
+
+ if (response.error) {
+ $('#error-text').text(response.error);
+ $('.alert').slideDown();
+ } else {
+ $('#output').text(response.result);
+ $('.content').slideUp();
+ $('.result').slideDown();
+ }
+ }).fail(function(xhr) {
+ $('#error-text').text(xhr.responseText);
+ $('.alert').slideDown();
});
});
});