// urbanstudio GmbH /* global listeners */ addEventListener('load', function() { setTimeout(US_hideAddressBar, 0); }, false); /* global functions */ function US_createCookie(name,value,days){ if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function US_readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function US_eraseCookie(name){ createCookie(name,"",-1); } function US_doLogin(){ //alert("Login!"); var ref = $("#ref").val().length >= 1 ? $("#ref").val().replace("http:///", "https://").replace("https:///", "https://")+"?forcelang="+$("#lang").val() : '/'+$("#lang").val(); //if($("#lang").val() != $("loginlang").val()) ref = '/'+(typeof $("loginlang").val() == "undefined" ? ref : $("loginlang").val()); var login_poststring = "&loginuser="+$("#loginuser").val()+"&loginpass="+encodeURIComponent($("#loginpass").val())+"&PHPSESSID="+$("#PHPSESSID").val()+"&lang="+$("#lang").val()+"&todo=login"; $.post("/login.php", login_poststring, function(resp){ if(resp.indexOf("Fehler") != -1){ $(".message, .message-error, .message-success").hide().remove(); US_showMessage('logintext', ''+resp.substr(8)+'', 10, 'message-error'); return false; }else{ window.location.href=''+ref+''; /*alert(resp); */ } }); } function US_doSBLogin(){ //alert("Login!"); var ref = $("#ref").val().length >= 1 ? $("#ref").val().replace("http:///", "https://").replace("https:///", "https://") : '/'; var login_poststring = "&loginuser="+$("#sbloginuser").val()+"&loginpass="+encodeURIComponent($("#sbloginpass").val())+"&isag="+$("#isag").val()+"&kdsid="+$("#kdsid").val()+"&ult="+$("input[name=ult]:checked").val()+"&PHPSESSID="+$("#PHPSESSID").val()+"&todo=login"; $.post("/login.php", login_poststring, function(resp){ if(resp.indexOf("Fehler") != -1){ $(".message, .message-error, .message-success").hide().remove(); US_showMessage('sbloginform', ''+resp.substr(8)+'', 10, 'message-error'); return false; }else{ window.location.href=''+ref+''; /*alert(resp); */ } }); } function US_hideAddressBar(){ window.scrollTo(0, 0); } function US_showMessage(obj,text,time,type){ var rand = Math.floor(Math.random()*113); $('#'+obj+'').prepend('
'); if(!time) { var time=4000;} else { time=time*1000;} if(!type) {void(0);} else { $('#message'+rand).removeClass().addClass(type); } $('#message'+rand).animate({ opacity: 'show', height: 'show' }, 'normal'); $('#message'+rand+' span').click(function(){ $(this).parent().animate({ opacity: "hide", height: "hide" }, "fast", function(){ $('#message'+rand+'').remove(); }); }); window.setTimeout(function(){ $('#message'+rand+'').animate({ opacity: "hide", height: "hide" }, "fast", function(){ $('#message'+rand+'').remove(); }); },time); } function US_confirm(options){ $('.confirmbox').remove(); var defaults = { dialogid : "dialog1", dialogtype : "confirm", buttons: { "ok": "close" }, message : "Willst du die Aktion wirklich ausführen?" } options = $.extend({}, defaults, options); /*if(options.dialogtype == "confirm"){ alert("confirmbox"); }else{*/ var self = $("body").prepend(''); $.each(options.buttons, function(name, props) { props = $.isFunction( props ) ? { click: props, text: name } : (props == "close" ? { click : function () { $("#"+options.dialogid+"").fadeOut("fast", function(){ $(this).remove(); }); }, text : name } : ''); //if(props == "close"){ props.click = 'function () { $("#"+options.dialogid+"").slideUp("slow").remove(); }'; } var button = $('') .attr(props, true).unbind('click').click(props.click) .appendTo($("#"+options.dialogid+" > div > div")); }); /* just add a bit math magic for the beauty */ $('.confirmbox').width($(document).width()).height($(document).height()); $('.confirmbox > div').offset({ top: window.pageYOffset+($(window).height()/2)-($('.confirmbox > div').height()/1.2), left: ($(window).width()/2)-250 }); $(window).resize(function(){ $('.confirmbox').width($(document).width()).height($(document).height()); $('.confirmbox > div').offset({ top: window.pageYOffset+($(window).height()/2)-($('.confirmbox > div').height()/1.2), left: ($(window).width()/2)-250 }); }).keyup(function(e){ if(e.keyCode == 27){ $('.confirmbox').fadeOut("fast", function(){ $(this).remove(); }); } }); $('.confirmbox button:first-child').addClass('red').focus(); /*}*/ } function US_custombox(options){ $('.custombox').remove(); var defaults = { dialogid : "dialog1", dialogtype : "confirm", buttons: { "ok": "close" }, message : "Willst du die Aktion wirklich ausführen?" } options = $.extend({}, defaults, options); var self = $("body").prepend(''); $.each(options.buttons, function(name, props) { props = $.isFunction( props ) ? { click: props, text: name } : (props == "close" ? { click : function () { $("#"+options.dialogid+"").fadeOut("fast", function(){ $(this).remove(); }); }, text : name } : ''); //if(props == "close"){ props.click = 'function () { $("#"+options.dialogid+"").slideUp("slow").remove(); }'; } var button = $('').attr(props, true).unbind('click').click(props.click).appendTo($("#"+options.dialogid+" > div > div")); }); /* just add a bit math magic for the beauty */ $('.custombox').width($(document).width()).height($(document).height()); $('.custombox div.conbox').css({ 'margin-top': window.pageYOffset+($(window).height()/2)-($('.custombox div.conbox').height()/2) }); if($.browser.msie){ $('.custombox div.conbox').css({ 'margin-top': document.body.scrollTop+($(window).height()/2)-($('.custombox div.conbox').height()/2) });} //------$('.custombox div.conbox').css({ 'top': ($(window).height()/2)-($('.custombox div.conbox').height()/2) }); $(window) .scroll(function(){ $('.custombox div.conbox').css({ 'margin-top': window.pageYOffset+($(window).height()/2)-($('.custombox div.conbox').height()/2) }); if($.browser.msie){ $('.custombox div.conbox').css({ 'margin-top': document.body.scrollTop+($(window).height()/2)-($('.custombox div.conbox').height()/2) });} }).resize(function(){ $('.custombox').width($(document).width()).height($(document).height()); $('.custombox div.conbox').css({ 'margin-top': window.pageYOffset+($(window).height()/2)-($('.custombox div.conbox').height()/2) }); if($.browser.msie){ $('.custombox div.conbox').css({ 'margin-top': document.body.scrollTop+($(window).height()/2)-($('.custombox div.conbox').height()/2) });} }).keyup(function(e){ if(e.keyCode == 27){ $('.custombox').fadeOut("fast", function(){ $(this).remove(); }); } }); $('.custombox button:first-child').addClass('red').focus(); } function US_delete(options){ var defaults = {subtable : "none", mycallback: function(){}}; options = $.extend({}, defaults, options); if(options.table == "" || options.idnametodel == "" || options.idtodel == "" || $.type(options.idtodel) != "number"){ US_showMessage("Die Auswahl kann nicht entfernt werden.", 5, "message-error"); }else{ var order = "&todo=delete&table="+options.table+"&idtodel="+options.idtodel+"&idnametodel="+options.idnametodel+"&subtable="+options.subtable; $.post("/helper/ajax/delete.php", order, function(theResponse){ if(theResponse.substr(0,6) == "Fehler"){ US_showMessage(theResponse, 5, "message-error"); }else{ US_showMessage(theResponse, 5, "message-success"); options.mycallback; } }); } } function myserialize(s1){ var myserial = ""; var s = "list"; $("#"+s1+" > div").each(function(){ myserial += "&"+s+"[]="+$(this).attr("id").substr(4); }); //alert(s1+" - "+myserial); return myserial; } function US_secureString(s){return s.replace(/\./g," ").replace(/[^A-Z,a-z,0-9,_,-,ä,ü,ö,Ä,Ü,Ö,ß, ]/g,"")} function US_URLString(s){return s.replace(/\ /g,"-").replace(/[^A-Z,a-z,0-9,_,-]/g,"").toLowerCase()} function US_stripTags(s){return s.replace(/<[a-z,\/]{1,}[^<]*>/g," ")} function US_maskTags(s){return s.replace(//g,">")} function US_getFileExt(s){return s.match(/\.[a-z,0-9]*$/g)} function US_defined(v){return (typeof v !== "undefined")} function US_validMail(s){return s.match(/[a-z,0-9,_,-,.]{1,}@[a-z,0-9,-,.]*\.[a-z]{2,6}/g) == s;} function US_filesize(fz){ if (fz < 1024) return fz +' B'; else if (fz < 1024*1024) return Math.round((fz / 1024) * 100)/100 +' KB'; else if (fz < 1024*1024*1024) return Math.round((fz / (1024 * 1024)) * 100)/100 +' MB'; else if (fz < 1024*1024*1024*1024) return Math.round((fz / (1024 * 1024 * 1024)) * 100)/100 +' GB'; else if (fz < 1024*1024*1024*1024*1024) return Math.round((fz / (1024 * 1024 * 1024 * 1024)) * 100)/100 +' TB'; else return Math.round((fz / (1024 * 1024 * 1024 * 1024 * 1024)) * 100)/100 +' PB'; } function US_mysqlTimestampToDate(ts){var d=ts.match(/[0-9]{2,4}/gi);return new Date(d[0],d[1]-1,d[2],d[3],d[4],d[5]);} function US_formatDate(da){days=["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"];return days[da.getDay()]+", "+da.getDate()+"."+da.getMonth()+"."+da.getFullYear()+" "+da.getHours()+":"+da.getMinutes();} US_fifo=function() { this.d = []; this.i = function(o) { this.d.push(o); } this.o = function() { if(this.d.length) { var t = this.d[0]; this.d.splice(0,1); return t; } else { return false; } } } function showPasttime(zeit){ var nd = new Date(); var jetzt = nd.getTime()/1000; var sec = jetzt-zeit; if(sec < 60){ return "gerade eben"; } if(sec < 3600){ return "vor "+Math.ceil(sec/60)+" Minuten"; } if(sec < 60*60*24){ return "vor "+Math.ceil(sec/60/60)+" Stunden"; } if(sec < 60*60*24*7){ return "vor "+Math.ceil(sec/60/60/24)+" Tage"; } if(sec < 60*60*24*30){ return "vor "+Math.ceil(sec/60/60/24/7)+" Woche(n)"; } if(sec < 60*60*24*30*12){ var monanz = Math.ceil(sec/60/60/24/30); if(monanz <= 2){ return "vor "+Math.ceil(sec/60/60/24/30)+" Monat(en)"; }else{ var t2s = new Date(zeit*1000); return "am "+t2s.getDate()+"."+(parseInt(t2s.getMonth())+1)+"."+t2s.getFullYear(); } } //return "vor "+Math.ceil(sec/60/60/24/365)+" Jahr(e)"; var t2s = new Date(zeit*1000); return "am "+t2s.getDate()+"."+(parseInt(t2s.getMonth())+1)+"."+t2s.getFullYear(); }