• Webspell RM Das Bootstrap Clan und Gamer CMS
logo
  • News
  • Forum
  • Demo
  • WIKI
  • ANMELDEN
  • Registrieren
  • DOWNLOAD RM

 Forum

    Du bist hier: 
  1. Forum
  2. Plugins und Modifikationen
  3. Modifikationen
  4. Cookiescript

Sortierung

 

Thema: Cookiescript

129
blubber

Administrator


RM-Support


rank

offline

Beiträge 94

11.03.2019

Grüße euch alle laugh,

ich habe bisschen am cookiescript gespielt und evtl. wollt ihr es ja mal testen =).
!!! WICHTIG !!! Backup nicht vergessen !!! WICHTIG !!!

1. Cookie ist 1 Jahr gültig ( Änderbar in der Scriptfunktion )

2. Slider der ausfährt zum akzeptieren

3. Seitenrefresh auf der Seite -> Bsp: Login -> cookie akzeptieren -> refresh auf der Login =)

Geht in eure index.php des Themes ( Beispiel: /includes/themes/default/index.php )

Sucht die Zeile ( weit unten ) mit folgenden Inhalt:

<div id="footer-cookie">
    <span id="description"><?php echo $index_language[ 'cookie-text' ];?>
       <span id="privacy_policy"><a href="datenschutz.html"><?php echo $index_language[ 'privacy' ];?></a></span>
    </span>
    <span id="accept"><a href="javascript:void(0)" title="Akzeptieren"><?php echo $index_language[ 'accept' ];?></a></span>
  </div>

  <script>    
    var footerCookie = document.querySelector("#footer-cookie");
    var footerCookieAccept = document.querySelector("#accept");

    if (document.cookie.indexOf("cookie=") == -1) {
      footerCookie.style.display = "block";
    }

    footerCookieAccept.onclick = function(e) {

    		var cookieDate = new Date();
            cookieDate.setTime(cookieDate.getTime() + (1*24*60*60*1000));
            var expires = "expires="+cookieDate.toUTCString();
            document.cookie = "cookie" + "=accepted" + "; " + expires + cookieDate.toUTCString();
            footerCookie.style.display = "none";
    };
  </script>

 

und ersetzt es mit diesem:

 

    <div class="alert alert-dismissible text-center cookiealert" role="alert">
      <div class="cookiealert-container">
        &#x1F36A; <b>Cookies</b>. 
        <span id="description"><?php echo $index_language[ 'cookie-text' ];?>
          <span id="privacy_policy"><a href="datenschutz.html"><?php echo $index_language[ 'privacy' ];?></a></span>
        </span>
        <span id="accept"><a class="btn btn-primary btn-sm acceptcookies" aria-label="Close" href="" title="Akzeptieren"><?php echo $index_language[ 'accept' ];?></a></span>
      </div>
    </div>

    <script>
      (function () {
        "use strict";

        var cookieAlert = document.querySelector(".cookiealert");
        var acceptCookies = document.querySelector(".acceptcookies");

        if (!cookieAlert) {
          return;
        }

        cookieAlert.offsetHeight; // Force browser to trigger reflow (https://stackoverflow.com/a/39451131)

        // Show the alert if we cant find the "acceptCookies" cookie
        if (!getCookie("cookie")) {
          cookieAlert.classList.add("show");
        }

        // When clicking on the agree button, create a 1 year
        // cookie to remember user's choice and close the banner
        acceptCookies.addEventListener("click", function () {
          setCookie("cookie", "accepted", 365);
          cookieAlert.classList.remove("show");
          setTimeout(function(){ window.location.reload(); });
        });

        // Cookie functions from w3schools
        function setCookie(cname, cvalue, exdays) {
          var d = new Date();
          d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
          var expires = "expires=" + d.toUTCString();
          document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
        }

        function getCookie(cname) {
          var name = cname + "=";
          var decodedCookie = decodeURIComponent(document.cookie);
          var ca = decodedCookie.split(';');
            for (var i = 0; i < ca.length; i++) {
              var c = ca[i];
              while (c.charAt(0) === ' ') {
                c = c.substring(1);
              }
              if (c.indexOf(name) === 0) {
                return c.substring(name.length, c.length);
              }
            }
            return "";
        }
    })();
  </script>

zum Schluss öffnet ihr die "components/css/cookie.css" und ersetzt den code mit diesem:

.cookiealert {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    margin: 0 !important;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    border-radius: 0;
    transform: translateY(100%);
    transition: all 500ms ease-out;
    color: #ecf0f1;
    background: #212327;
}

.cookiealert.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0%);
    transition-delay: 1000ms;
}

.cookiealert a {
    text-decoration: underline
}

.cookiealert .acceptcookies {
    margin-left: 10px;
    vertical-align: baseline;
}


Das wars auch schon =). Feedback mit Daumen hoch :D


13.08.2022 | 15:50
Es bedanken sich: Argu, McRobert

Sortierung

 



Um ein Thema zu eröffnen musst du registriert und angemeldet sein!

• registrieren
• anmelden

Webspell RM ist ein Open Source CMS welches speziell für Clan- und Community-Seiten entwickelt wird und auf Bootstrap basiert.

Community

  • Mitglieder
  • Referenzen
  • Unsere Partner
  • News Archiv
  • Webspell-RM Team

Quick Links

  • Download
  • Demo
  • ToDo
  • Github
  • RM-Projekte

Wir im Social Web

Chatte mit uns auf Discord oder folge uns auf Facebook & Twitter.

  • Discord
  • Facebook
  • Twitter

Webspell RM Das Bootstrap Clan und Gamer CMS

  • Impressum
  • Datenschutz
  • Kontakt
  • Counter
Diese Website verwendet Cookies. Wenn Sie diese Website nutzen stimmen Sie der Verwendung von Cookies zu!. Hier erfahrt ihr alles zum Datenschutz Akzeptieren