Add error and info popups
authorJoey Schulze <joey@infodrom.org>
Sun, 9 Jul 2017 11:20:22 +0000 (13:20 +0200)
committerJoey Schulze <joey@infodrom.org>
Mon, 10 Jul 2017 20:48:29 +0000 (22:48 +0200)
src/infodrom.css
src/infodrom.js

index 788fe08..bc5cb1a 100644 (file)
@@ -183,6 +183,33 @@ table#fc {
   z-index: 100;
 }
 
   z-index: 100;
 }
 
+/*
+ * jQuery & Co.
+ */
+div#message_div {
+    background: #ffffcd;
+    color: #555;
+    border: 1px solid limegreen;
+    font-size: 120%;
+    padding: 5px;
+}
+div#error_div {
+    background: #ddd;
+    color: #555;
+    border: 1px solid red;
+}
+div#error_div div {
+    font-size: 120%;
+    font-weight: bold;
+    padding: 5px;
+}
+div#error_div p {
+    text-align: right;
+    padding: 2px;
+    margin: 0;
+    border-bottom: 1px solid #CCC;
+}
+
 /*
  * Footer
  */
 /*
  * Footer
  */
@@ -199,9 +226,3 @@ div.footerright {
   font-size: xx-small;
 }
 
   font-size: xx-small;
 }
 
-/*
- * Local variables:
- * mode: indented-text
- * mode: auto-fill
- * End:
-*/
index c27a86b..869c8c7 100644 (file)
@@ -25,3 +25,53 @@ function ajax_request(funcname, params, callback, error_callback)
                   callback(data);
           });
 }
                   callback(data);
           });
 }
+
+function show_message(text, timeout)
+{
+    if (typeof timeout == 'undefined') timeout = 3;
+
+    var div = $('#message_div');
+    if (!div.length) {
+       div = $('<div>');
+       div.attr('id', 'message_div').css('z-index','1000');
+       div.hide();
+       $(document.body).append(div);
+    }
+
+    div.text(text);
+    div.center();
+    div.show();
+
+    window.setTimeout(hide_message,timeout*1000);
+}
+
+function hide_message(text)
+{
+    $('#message_div').hide();
+}
+
+function show_error(text, timeout)
+{
+    var div = $('#error_div');
+    if (!div.length) {
+       div = $('<div>');
+       div.attr('id', 'error_div').css('z-index','1000');
+       div.hide();
+       div.append($('<p ><img src="/pix/close.gif" title="close" onclick="return hide_error()"/></p>'));
+       div.append($('<div />'));
+       $(document.body).append(div);
+    }
+
+    div.find('div').html(text);
+    div.center();
+    div.show();
+
+    if (typeof timeout != 'undefined')
+       window.setTimeout(hide_error,timeout*1000);
+}
+
+function hide_error(text)
+{
+    $('#error_div').hide();
+    return false;
+}