From 261bf4792684475820ad12d26287613938778636 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 18 Jul 2021 16:19:12 +0200 Subject: [PATCH] cookiebanner --- README.md | 13 +++++++++++++ cookiebanner.css | 15 +++++++++++++++ cookiebanner.js | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 cookiebanner.css create mode 100644 cookiebanner.js diff --git a/README.md b/README.md index d8a3be0..79e4bf3 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,19 @@ git submodule add https://git.seemsleg.it/pub/cssjs-func-lib cssjs ``` +## Cookiebanner +``` + + + +``` + ## ckEditor5 ``` diff --git a/cookiebanner.css b/cookiebanner.css new file mode 100644 index 0000000..3679e61 --- /dev/null +++ b/cookiebanner.css @@ -0,0 +1,15 @@ +#cookiebanner { + margin: 0px; + padding: 6px; + position: fixed; + bottom: 0; + left: 0; + background-color: #000; + color: #fff; + text-align: center; + width: 100%; + z-index: 9; +} +#cookiebanner button { + margin-left: 6px; +} \ No newline at end of file diff --git a/cookiebanner.js b/cookiebanner.js new file mode 100644 index 0000000..700f57c --- /dev/null +++ b/cookiebanner.js @@ -0,0 +1,35 @@ +function setCookiebannerCookie(val) { + document.cookie = cookiebanner_cookie +"="+val+"; expires=Fry, 01 Jan 2038 00:00:00 UTC; path=/;"; + document.getElementById('cookiebanner').remove(); +} + +(function() { + function getCookie(name) { + const value = `; ${document.cookie}`; + const parts = value.split(`; ${name}=`); + if (parts.length === 2) + return parts.pop().split(';').shift(); + return false; + } + + // + + if(!getCookie(cookiebanner_cookie)) { + var cookiebanner = document.createElement('div'); + cookiebanner.setAttribute('id','cookiebanner'); + cookiebanner.append(document.createTextNode(text)); + cookiebanner.append(document.createElement('br')); + + var ack = document.createElement('button'); + ack.setAttribute('onclick','setCookiebannerCookie("ok");'); + ack.append(document.createTextNode('Ja')); + cookiebanner.append(ack); + + var nak = document.createElement('button'); + nak.setAttribute('onclick','setCookiebannerCookie("nope");'); + nak.append(document.createTextNode('Nein')); + cookiebanner.append(nak); + + document.body.appendChild(cookiebanner); + } +})(); \ No newline at end of file