1 function show_message(text, timeout)
3 if (typeof timeout == 'undefined') timeout = 3;
5 var div = $('#message_div');
8 div.attr('id', 'message_div').css('z-index','1000');
10 $(document.body).append(div);
17 window.setTimeout(hide_message,timeout*1000);
20 function hide_message(text)
22 $('#message_div').hide();
25 function show_error(text, timeout)
27 var div = $('#error_div');
30 div.attr('id', 'error_div').css('z-index','1000');
32 div.append($('<p ><img src="/pix/close.gif" title="close" onclick="return hide_error()"/></p>'));
33 div.append($('<div />'));
34 $(document.body).append(div);
37 div.find('div').html(text);
41 if (typeof timeout != 'undefined')
42 window.setTimeout(hide_error,timeout*1000);
45 function hide_error(text)
47 $('#error_div').hide();
52 $.fn.ltag = function() {
53 return this.prop("tagName").toLowerCase();
56 $.fn.center = function () {
57 this.css("position","absolute");
58 this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) +
59 $(window).scrollTop()) + "px");
60 this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) +
61 $(window).scrollLeft()) + "px");
65 $.invoke = function(name, parms, callback) {
66 if (typeof(parms) == 'string' && parms.length)
67 parms = 'route='+name+'&'+parms;
68 else if (typeof(parms) == 'object')
69 parms['route'] = name;
71 parms = 'route='+name;
78 if (data.redirect_login) {
79 show_message(data.error, 5);
80 setTimeout(function(){window.location.href = '/';}, 5000);
83 return show_error(data.error);
85 return show_error('Fehler im Backend zu "'+name+'" aufgetreten');
87 if (typeof(data.html) == 'object')
88 for (id in data.html) {
91 elem.html(data.html[id]);
94 if (typeof(data.values) == 'object')
95 for (id in data.values) {
98 elem.val(data.values[id]);
101 if (typeof(callback) == 'function')
102 return callback(data);