-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcookie-consent.html
More file actions
58 lines (52 loc) · 2.02 KB
/
cookie-consent.html
File metadata and controls
58 lines (52 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<div class="cookie-notice" id="cookie-notice">
<i onclick="hideConsent()" class="close-consent fa fa-times close"></i>
<div class="cookie-container">
<span>
{% assign lang = page.lang | default: site.lang | default: 'pl' %}
{{ site.data.translations['cookieConsent'][lang] }}
</span>
<a id="cookie-notice-accept" class="consent-button">{{ site.data.translations['cookieConsentApprove'][lang] }}</a>
</div>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=300808861525851&ev=PageView&noscript=1"
/></noscript>
</div>
<script>
function createCookie(name, value, days) {
let expires = "";
if (days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
const nameEQ = name + "=";
const ca = document.cookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name, "", -1);
}
function hideConsent() {
document.getElementById('cookie-notice').style.display = 'none';
}
if (readCookie('cookie-notice-dismissed') === 'true') {
{%- if jekyll.environment == 'production' -%}
{%- include facebook-pixel.js -%}
{%- endif -%}
} else {
document.getElementById('cookie-notice').style.display = 'flex';
}
document.getElementById('cookie-notice-accept').addEventListener("click", function () {
createCookie('cookie-notice-dismissed', 'true', 31);
hideConsent();
location.reload();
});
</script>