This repository has been archived on 2024-09-12. You can view files and clone it, but cannot push or open issues or pull requests.
svrjs-website/themes/svrjswebsite/source/js/matomooptout.js

23 lines
783 B
JavaScript
Raw Permalink Normal View History

2024-04-25 16:40:57 +02:00
document.addEventListener("DOMContentLoaded", function(event) {
function setOptOutText(element) {
_paq.push([function() {
element.checked = !this.isUserOptedOut();
element.disabled = false;
(document.querySelector ? document.querySelector('label[for=optout] strong') : document.getElementById('optoutlabel')).innerHTML = this.isUserOptedOut()
? 'You are currently opted out. Click here to opt in.'
: 'You are currently opted in. Click here to opt out.';
}]);
}
var optOut = document.getElementById("optout");
optOut.addEventListener("click", function() {
if (this.checked) {
_paq.push(['forgetUserOptOut']);
} else {
_paq.push(['optUserOut']);
}
setOptOutText(optOut);
});
setOptOutText(optOut);
});