// use: jquery // or make the call at the and of the html-page! // //jQuery( document ).ready( function() //{ // var oCI = new PPDInfoMsgBar(); // oCI.showCookieBar(); //}); function PPDInfoMsgBar() { // ------------------------------------------------------------------------- // var _COOKIEVAL_OK = "y"; // set for "ok" var _COOKIEVAL_CLS = "c"; // set for "close" [x] var _COOKIEVAL_NONE = ""; // some optional value (not used) // // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // var iLifeTime_Years = 1; // the life time for the message cookie in "years" // // ------------------------------------------------------------------------- // - msg text field -------------------------------------------------------- // var _SPAN_TYPE_ = "snt"; var _TD_TYPE_ = "tdt"; // // ------------------------------------------------------------------------- // - div position ---------------------------------------------------------- // var sDivPosition = "bottom"; //var sDivPosition = "top"; // // - links / buttons ------------------------------------------------------- // var sBtnOkTxt = "Gelesen und Einverstanden"; var sBtnInfoTxt = ""; // empty = no anchor elem var sCloseChar = "x"; var sClsIconHint = "schlie\u00DFen"; // // - more info target ------------------------------------------------------ // var _MOREINFO_ELEM_TEMPL_ = ""; var sMoreInfoTxtVal = "Datenschutzerkl\u00E4rung"; var sMoreInfoTxtTitle = "Datenschutzerkl\u00E4rung lesen"; //var sMoreInfoTxtTarget = "_blank"; // -> popup window var sLinkHref = "#"; //var sMoreInfoTarget = "_blank"; // -> popup window // - popup: var sInfoTargetUrl = "/popups/datenschutz.php"; // the url (to "Datenschutz" ...) var rgsHideInfoBtnFor = new Array( sInfoTargetUrl, "datenschutz.html" ); var sInfoTargetWinName = "cookieinfo_moreinfo_name"; var iPopupAW = Math.ceil( screen.availWidth * 2 / 3 ); var iPopupAH = Math.ceil( screen.availHeight * 3 / 4 ); var iPopupMW = 720; var iPopupMH = 640; var iPopupW = Math.min( iPopupAW, iPopupMW ); var iPopupH = Math.min( iPopupAH, iPopupMH ); var sMoreInfoWinProp = "height=" + iPopupH + "px, " + "width=" + iPopupW + "px, " + "location=yes," + "menubar=yes," + "resizable=yes," + "status=yes," + "titlebar=yes," + "scrollbars=yes," + "top=" + ( ( screen.availHeight - iPopupH ) / 2 ) + "px," + "left=" + ( ( screen.availWidth - iPopupW ) / 2 ) + "px" + ""; // // - div style ------------------------------------------------------------- // var sAllCSSClass = "mdmxAll"; var sMobCSSClass = "mdmxmobile"; // var sDivCSS = "position: fixed; " + "width: 100%; " + "background-color: #eeeeee; " + "background-color: rgba( 238, 238, 238, 0.8 ); " + "margin: 0px; " + "left: 0px; " + sDivPosition + ": 0px; " + "padding: 4px; " + "z-index: 9999; " + "text-align: center;"; var sCtrlStyle = "width: 100%; " + "margin: 0px; " + "padding: 0px; " + "float: right; " + "text-align: center;"; var sTextCSS = "padding: 11px 12px 12px 11px;"; var sClsIconCSS = "width: 12px; " + "height: 12px; " + "border-width: 0px; " + "font-family: sans-serif; " + "font-size: 0.6em; " + "font-weight: bold; " + "position: relative; " + "top: -18px; " + "right: -15px; " + "background-color: #cccccc; " + "color: #cc3333; " + ""; // // -- use close-button ------------------------------------------------------- // var boWithCloseBtn = false; // do not show an extra [x]-close-btn // var sPPDMoreInfoID = "ppdmoreinfo_id"; // // - div message ----------------------------------------------------------- // var rgsMsgTxt = new Array( "Bitte lesen Sie unsere ", _MOREINFO_ELEM_TEMPL_, ". " + "Mit der Nutzung unserer Webseite erkl\u00E4ren Sie sich mit " + "dem Inhalt der ", _MOREINFO_ELEM_TEMPL_, " " + "und der Verwendung von Cookies einverstanden." ); // // // --------------------------------------------------------------------------- var sCookieInfoName = "_display_cookie_ppd_consent"; var sCookieConsentID = "cookieinfo_id"; var sCtrlClass = "cookieinfo_ctrl"; var sCloseLinkID = "cookieclose_id"; var sCloseIconID = "cookiecloseicon_id"; var sMoreInfoID = "cookiemoreinfo_id"; var oThis = null; // only "OK": var oRegExpCookieOK = new RegExp( sCookieInfoName + "=(" + _COOKIEVAL_OK + ")" ); // only "CLS": var oRegExpCookieCLS = new RegExp( sCookieInfoName + "=(" + _COOKIEVAL_CLS + ")" ); //new RegExp( sCookieInfoName + "=([^;]+)" ); // any not empty value ... var oRegExpIsInfoTarget = null; var iPPDMInfoIndex = 0; var iPPDMCloseIndex = 0; var boIsInit = false; var boHideMoreInfo = false; this.init = function() { if( boIsInit === true ) { return; } oThis = this; var sCurrLocation = window.location.href; var sPrepUrl = ""; var rgsMatches = null; for( var h=0, l=rgsHideInfoBtnFor.length; h 0 ) { for( var i=0, l=rgsMsgText.length, sMsgPart="", oAppend=null; i 0 ) { for( var p=iPPDMInfoIndex; p>0; p-- ) { document.getElementById( sPPDMoreInfoID + p ).onclick = this.openInfoWindow; } } if( iPPDMCloseIndex > 0 ) { for( var p=iPPDMCloseIndex; p>0; p-- ) { document.getElementById( sCloseLinkID + p ).onclick = this.closeClick; } } if( boWithCloseBtn === true ) { document.getElementById( sCloseIconID ).onclick = this.closeClick; } if( boHideMoreInfo === false && this.isEmpty( sLinkText ) === false && this.isEmpty( sLinkHref ) === false ) { document.getElementById( sMoreInfoID ).onclick = this.openInfoWindow; } } }; this.removeMsgDiv = function() { var oElem = document.getElementById( sCookieConsentID ); if( this.isEmpty( oElem ) === false ) { oElem.parentNode.removeChild( oElem ); } }; /** * set the "do not show the message again" - cookie * * using a hierarchie, thus "close"-value will not overwrite "ok"-value! * * @param {string} sValue should be one of the given values: * _COOKIEVAL_OK or _COOKIEVAL_CLS, * if empty then autom.: _COOKIEVAL_NONE is set * @returns void */ this.setCookie = function( sValue ) { var boHasOKCookie = this.isOKCookieSet(); var sSetVal = ( this.isEmpty( sValue ) === true ) ? _COOKIEVAL_NONE : sValue; if( sSetVal !== _COOKIEVAL_OK && boHasOKCookie === true ) { return; // do not overwrite, i.e. do not reset "ok"! } // start: today var oExpireDate = new Date(); // set the cookie expires after 1 year oExpireDate.setFullYear( oExpireDate.getFullYear() + iLifeTime_Years ); document.cookie = sCookieInfoName + "=" + sSetVal + ";" + "path=/; " + "expires=" + oExpireDate.toGMTString(); }; /** * only true for _COOKIEVAL_OK ( = "y" ) * * for any other value: false * * * @returns result of testing if the cookie just exists * (using a reg.exp. with the full cookie name and a not empty value) */ this.isOKCookieSet = function() { // check if the cookie has been set return !!document.cookie.match( oRegExpCookieOK ); }; /** * only true for _COOKIEVAL_CLS ( = "y" ) * * for any other value: false * * * @returns result of testing if the cookie just exists * (using a reg.exp. with the full cookie name and a not empty value) */ this.isCLSCookieSet = function() { // check if the cookie has been set return !!document.cookie.match( oRegExpCookieCLS ); }; this.openInfoWindow = function() { if( oThis === null || typeof oThis === "undefined" ) { var oCI = new PPDInfoMsgBar(); oThis = oCI; } oThis.closeClick(); // hide temp. the message ... return window.open( sInfoTargetUrl, sInfoTargetWinName, sMoreInfoWinProp ); }; };