Verified Commit 4beb1da7 authored by Laurent Heirendt's avatar Laurent Heirendt
Browse files

integrate get cookie

parent ef918f8e
......@@ -5,26 +5,6 @@
var _paq = window._paq || _paq || [];
/*
getCookie: retrieve a cookie that has been set.
inspired from https://www.w3schools.com/js/js_cookies.asp
*/
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 "";
}
/* loadMatomo: load the tracking code of the matomo instance */
function loadMatomo() {
if (settings.siteID > 0) {
......@@ -88,7 +68,6 @@ $( document ).ready(function() {
jQuery('.lap-cookies-refuse').removeClass('disabled');
jQuery(this).blur();
// if the lap_cookie_agree is already set to one, do not load matomo again
loadMatomo();
setResultText(true);
});
......@@ -112,8 +91,19 @@ $( document ).ready(function() {
jQuery('.lap-cookies-accept, .lap-cookies-refuse').addClass('disabled');
}
} else {
lapCookieAgree = getCookie('lap_cookie_agree');
var lapCookieAgree = '';
var name = 'lap_cookie_agree=';
var ca = decodeURIComponent(document.cookie).split('; ');
for(var k = 0; k <ca.length; k++) {
var c = ca[k];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
lapCookieAgree = c.substring(name.length, c.length);
}
}
console.log(lapCookieAgree);
if (lapCookieAgree == '0') {
/* visitor refused cookies => remove Matomo trace if present */
jQuery('.lap-cookies-refuse').addClass('disabled');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment