1
0
Fork 0
hugo-matomo/static/assets/hugo-matomo.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-05-13 23:43:49 +00:00
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() {
2021-05-14 00:20:07 +00:00
t=Matomo.getAsyncTracker();
2021-05-13 23:43:49 +00:00
button = document.getElementById("cookiesaction");
text = button.parentNode.getElementsByTagName('span')[0]
2021-05-14 00:20:07 +00:00
if (!t.areCookiesEnabled()) {
2021-05-13 23:43:49 +00:00
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() {
2021-05-14 00:20:07 +00:00
t=Matomo.getAsyncTracker();
2021-05-13 23:43:49 +00:00
t.forgetCookieConsentGiven();
updateCookieConsent();
}
function startCookieConsent() {
2021-05-14 00:20:07 +00:00
t=Matomo.getAsyncTracker();
2021-05-13 23:43:49 +00:00
t.rememberCookieConsentGiven();
updateCookieConsent();
}