Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jesselau76/hugo-w3-simple.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjesselau76 <jesselau76@gmail.com>2018-11-29 06:53:34 +0300
committerjesselau76 <jesselau76@gmail.com>2018-11-29 06:53:34 +0300
commit429beb3ec8e68d6e0edde6175d138f02d556cc3a (patch)
tree5e34e0492045070aa8a4d18edefedc9214cdc2df /layouts
parentcc3e6d467ed184af4c85c04942c3b4b5cecc3aec (diff)
cookie law support
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/baseof.html63
1 files changed, 62 insertions, 1 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index b88c64c..f07a159 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -9,7 +9,9 @@
{{ . | safeHTML }}
{{ end }}
</head>
-<body class="w3-light-grey">
+<body {{ if .Site.Params.cookie_info }} onload="checkCookie()" {{ end }}
+
+class="w3-light-grey">
@@ -43,6 +45,65 @@
</div>
+<!-- cookie bar -->
+ {{ with .Site.Params.cookie_info }}
+ <div id="cookiebar" class="w3-bar w3-top w3-black w3-border " >
+ <span onclick="gotitcookiebar()"
+ class="w3-button w3-small w3-green w3-right">Got it</span>
+ <span class="w3-bar-item w3-small">{{ . | markdownify }}</span>
+ </div>
+
+
+<script>
+function gotitcookiebar() {
+ var x =document.getElementById("cookiebar");
+ x.style.display = "none";
+var x = document.getElementsByTagName("BODY")[0];
+ x.style.paddingTop = "0px";
+
+
+}
+
+
+
+function checkCookie() {
+ var user=getCookie("cookiebardisplayed");
+ if (user == "") {
+ var x =document.getElementById("cookiebar");
+ x.style.display = "block";
+ var h = document.getElementById('cookiebar').clientHeight;
+
+ var x = document.getElementsByTagName("BODY")[0];
+ x.style.paddingTop = h+"px";
+ setCookie("cookiebardisplayed","1",365);
+ }
+}
+function setCookie(cname,cvalue,exdays) {
+ var d = new Date();
+ d.setTime(d.getTime() + (exdays*24*60*60*1000));
+ var expires = "expires=" + d.toGMTString();
+ 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>
+{{ end }}
<!-- Back to top -->
{{ if .Site.Params.backtotop }}