Verified Commit 0b67c17f authored by Laurent Heirendt's avatar Laurent Heirendt
Browse files

streamlining and simplifications

parent 2755e85c
<div id="lap-cookies-banner">
<div class="banner-text">{{ site.banner_text }}</div>
<div class="banner-buttons">
<a class="btn lap-cookies-accept" href="">{{ site.banner_accept_text }}</a>
<a class="btn lap-cookies-refuse" href="">{{ site.banner_refuse_text }}</a>
<a class="btn lap-cookies-accept">{{ site.banner_accept_text }}</a>
<a class="btn lap-cookies-refuse">{{ site.banner_refuse_text }}</a>
<a class="btn lap-cookies-more" href="{{ site.path_policy }}">{{ site.banner_more_text }}</a>
</div>
</div>
\ No newline at end of file
......@@ -87,30 +87,56 @@ function hasConsent() {
}
}
$( document ).ready(function() {
/* accept */
$('.lap-cookies-accept').click(function (e) {
e.preventDefault(true);
/* accept: accept the cookies */
function accept(cookieMgmt) {
// action
loadMatomo();
// cookie management
if (cookieMgmt) {
setCookie(settings.cookieName, 1);
}
// feedback
hideCookieBanner();
setResultText(true);
// style
$('.lap-cookies-accept').addClass('disabled');
$('.lap-cookies-refuse').removeClass('disabled');
$(this).blur();
loadMatomo();
setResultText(true);
});
}
/* refuse */
$('.lap-cookies-refuse').click(function (e) {
e.preventDefault(true);
/* accept: refuse the cookies */
function refuse(cookieMgmt) {
// action
clearCookies();
// cookie management
if (cookieMgmt) {
setCookie(settings.cookieName, 0);
}
// feedback
hideCookieBanner();
setResultText(false);
// style
$('.lap-cookies-refuse').addClass('disabled');
$('.lap-cookies-accept').removeClass('disabled');
$(this).blur();
setResultText(false);
}
$( document ).ready(function() {
/* accept */
$('.lap-cookies-accept').click(function(e){
e.preventDefault(true);
accept();
});
/* refuse */
$('.lap-cookies-refuse').click(function(e){
e.preventDefault(true);
refuse();
});
// Detect if the visitor is a bot or not
......@@ -125,17 +151,14 @@ $( document ).ready(function() {
// Do nothing if it is a bot
// If DoNotTrack is activated, do nothing too
if (isBot || !isToTrack || !hasConsent()) {
hideCookieBanner();
$('.lap-cookies-refuse').addClass('disabled');
clearCookies();
refuse(false);
doNotTrack = true;
}
// User has already consent to use cookies to tracking
if (doNotTrack == false) {
if (hasConsent() === true) {
$('.lap-cookies-accept').addClass('disabled');
loadMatomo();
accept(true);
} else if (hasConsent() === false) {
// If it's not a bot, no DoNotTrack and not already accept, so show banner
showCookieBanner();
......
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