From 00ab2fcd0d7afea9b697559a5bd1275276fca5d6 Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Sun, 9 Jul 2017 13:20:22 +0200 Subject: [PATCH] Add error and info popups --- src/infodrom.css | 33 ++++++++++++++++++++++++++------ src/infodrom.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 6 deletions(-) diff --git a/src/infodrom.css b/src/infodrom.css index 788fe08..bc5cb1a 100644 --- a/src/infodrom.css +++ b/src/infodrom.css @@ -183,6 +183,33 @@ table#fc { 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 */ @@ -199,9 +226,3 @@ div.footerright { font-size: xx-small; } -/* - * Local variables: - * mode: indented-text - * mode: auto-fill - * End: -*/ diff --git a/src/infodrom.js b/src/infodrom.js index c27a86b..869c8c7 100644 --- a/src/infodrom.js +++ b/src/infodrom.js @@ -25,3 +25,53 @@ function ajax_request(funcname, params, callback, error_callback) callback(data); }); } + +function show_message(text, timeout) +{ + if (typeof timeout == 'undefined') timeout = 3; + + var div = $('#message_div'); + if (!div.length) { + 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.attr('id', 'error_div').css('z-index','1000'); + div.hide(); + div.append($('

')); + div.append($('
')); + $(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; +} -- 2.20.1