Get everything together
This commit is contained in:
parent
1be6b82419
commit
0e5c12ba90
7 changed files with 96 additions and 20 deletions
|
@ -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;
|
||||
}
|
45
static/assets/hugo-matomo.js
Normal file
45
static/assets/hugo-matomo.js
Normal 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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue