Added cookie box

This commit is contained in:
Aroy-Art 2021-05-27 14:05:19 +02:00
parent 604d75b972
commit 4fbbf5dc3d

View file

@ -62,3 +62,27 @@
{{ "<!-- Google Map API -->" | safeHTML }}
<script src="{{ site.Params.map.gmap_api | safeURL }}"></script>
{{ end }}
{{ if site.Params.cookies.enable }}
{{ "<!-- Cookie Box -->" | safeHTML }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js"></script>
<div id="js-cookie-box" class="cookie-box cookie-box-hide">
This site uses cookies. By continuing to use this website, you agree to their use. <span id="js-cookie-button" class="btn btn-transparent">I Accept</span>
</div>
<script>
(function ($) {
const cookieBox = document.getElementById('js-cookie-box');
const cookieButton = document.getElementById('js-cookie-button');
if (!Cookies.get('cookie-box')) {
cookieBox.classList.remove('cookie-box-hide');
cookieButton.onclick = function () {
Cookies.set('cookie-box', true, {
expires: {{ site.Params.cookies.expire_days }}
});
cookieBox.classList.add('cookie-box-hide');
};
}
})(jQuery);
</script>
{{ "<!-- /Cookie Box -->" | safeHTML }}
{{ end }}