New area to report status messages and errors
authorJoey Schulze <joey@infodrom.org>
Thu, 25 Feb 2010 18:20:39 +0000 (19:20 +0100)
committerJoey Schulze <joey@infodrom.org>
Thu, 25 Feb 2010 18:20:39 +0000 (19:20 +0100)
lib/functions.js
lib/mask.php
stylesheet.css

index 274483d..64bc2db 100644 (file)
@@ -6,7 +6,10 @@ function ajax_request_callback(req)
     if (req.readyState == 4 && req.status == 200) {
        var data = json_parse(req.responseText);
 
-       if (req.oncomplete)
+       if (typeof data.error == 'string') {
+           alert("Error in AJAX backend:\n" + data.error);
+           error('Fehler im AJAX-Backend');
+       } else if (req.oncomplete)
            req.oncomplete(data);
     }
 }
@@ -28,6 +31,24 @@ function ajax_request(func,params,oncomplete)
     req.send(params);
 }
 
+function info(msg)
+{
+    var status = document.getElementById('status');
+    if (!status) return;
+
+    status.innerHTML = msg;
+    status.className = 'status_ok';
+}
+
+function error(msg)
+{
+    var status = document.getElementById('status');
+    if (!status) return;
+
+    status.innerHTML = msg;
+    status.className = 'status_error';
+}
+
 function set_value(id, value)
 {
     var obj = document.getElementById(id);
index b60a650..e85e313 100644 (file)
@@ -136,6 +136,7 @@ function build_details($name, $details)
 function build_mask($name, $mask)
 {
   $grid = build_grid($name, $mask);
+  $status = array('<span id="status"></span><br>');
 
   if (array_key_exists('details', $mask))
     $details = build_details($name, $mask['details']);
@@ -153,6 +154,7 @@ function build_mask($name, $mask)
   return array_merge($head,
                     $grid,
                     array('</div>','<div class="left">'),
+                    $status,
                     $details,
                     array('</div>'));
 }
index b024617..4d30c6a 100644 (file)
@@ -58,3 +58,11 @@ table.login {
     position: relative;
     top: 290px;
 }
+
+span.status_ok {
+    color: green;
+}
+
+span.status_error {
+    color: red;
+}