1
0
Fork 0

Get everything together

This commit is contained in:
Carlos Mogas da Silva 2021-05-14 00:43:49 +01:00
parent 1be6b82419
commit 0e5c12ba90
7 changed files with 96 additions and 20 deletions

View file

@ -12,4 +12,11 @@
padding: 5px 14px;
display: flex;
text-align: center;
}
.consentCookieButton {
border-style: outset;
border-width: unset;
padding: 0 10px 0 10px;
margin-left: 20px;
}

View file

@ -0,0 +1,45 @@
function shouldShowPopup() {
dismissed = localStorage.getItem('popupDismissed');
banner = document.getElementsByClassName("cookie-banner")[0];
if (dismissed == null || dismissed === "no") {
banner.style.display = 'block';
}
}
function dismissPopup() {
localStorage.setItem('popupDismissed', 'yes');
banner = document.getElementsByClassName("cookie-banner")[0];
banner.style.display = 'none';
}
function updateCookieConsent() {
t=Matomo.getTracker(matomoHostURL, matomoSiteId);
when = t.getRememberedCookieConsent();
button = document.getElementById("cookiesaction");
text = button.parentNode.getElementsByTagName('span')[0]
if (when == 0) {
text.innerHTML = "You haven't allowed cookies to be used"
button.innerHTML = "Allow"
button.style.visibility = ""
button.onclick = function() { startCookieConsent(); }
} else {
text.innerHTML = "Using cookies to track your usage of the site"
button.innerHTML = "Stop"
button.style.visibility = ""
button.onclick = function() { stopCookieConsent(); }
}
}
function stopCookieConsent() {
t=Matomo.getTracker(matomoHostURL, matomoSiteId);
t.forgetCookieConsentGiven();
updateCookieConsent();
}
function startCookieConsent() {
t=Matomo.getTracker(matomoHostURL, matomoSiteId);
t.rememberCookieConsentGiven();
updateCookieConsent();
}