mirror of
https://github.com/sartography/spiffworkflow_website.git
synced 2025-02-24 13:28:29 +00:00
90 lines
4.0 KiB
HTML
90 lines
4.0 KiB
HTML
<div id="cookie-notice">
|
|
<span>We would like to use third party cookies and scripts to improve the
|
|
functionality of this website.</span>
|
|
<a id="cookie-notice-accept" class="btn btn-primary btn-sm">Approve</a>
|
|
<a id="cookie-notice-deny" class="btn btn-primary btn-sm">Deny</a>
|
|
<a href="/pages/privacy_policy/" class="btn btn-primary btn-sm">More info</a></div>
|
|
<script>
|
|
function createCookie(name,value,days) {
|
|
var expires = "";
|
|
if (days) {
|
|
var date = new Date();
|
|
date.setTime(date.getTime() + (days*24*60*60*1000));
|
|
expires = "; expires=" + date.toUTCString();
|
|
}
|
|
document.cookie = name + "=" + value + expires + "; path=/" + ";secure;SameSite=None";
|
|
}
|
|
function readCookie(name) {
|
|
var nameEQ = name + "=";
|
|
var ca = document.cookie.split(';');
|
|
for(var i=0;i < ca.length;i++) {
|
|
var c = ca[i];
|
|
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function deleteCookiesByPattern(pattern) {
|
|
const cookies = document.cookie.split(';');
|
|
|
|
for (let i = 0; i < cookies.length; i++) {
|
|
|
|
const cookie = cookies[i];
|
|
const eqPos = cookie.indexOf("=");
|
|
const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
|
|
|
|
if (name.includes(pattern)) {
|
|
// ADD YOUR DOMAIN HERE! KEEP THE DOT INFRONT, OTHERWISE THE COOKIE WONT GET DELETED
|
|
document.cookie = name + "=; Domain=.yourdomain.com; Path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; secure; SameSite=None";
|
|
}
|
|
}
|
|
}
|
|
|
|
if(readCookie('cookie-notice-option')=='true') {
|
|
{{ if hugo.IsProduction | or (eq .Site.Params.env "production") }}
|
|
|
|
function loadScriptAsync(scriptSrc, callback) {
|
|
if (typeof callback !== 'function') {
|
|
throw new Error('Not a valid callback for async script load');
|
|
}
|
|
var script = document.createElement('script');
|
|
script.onload = callback;
|
|
script.src = scriptSrc;
|
|
document.head.appendChild(script);
|
|
}
|
|
|
|
/* This is the part where you call the above defined function and "calls back"
|
|
your code which gets executed after the script has loaded */
|
|
//REPLACE WITH YOUR GA TAG!
|
|
loadScriptAsync('https://www.googletagmanager.com/gtag/js?id=G-3Z83G8WLEK', function () {
|
|
window.dataLayer = window.dataLayer || [];
|
|
function gtag() { dataLayer.push(arguments); }
|
|
gtag('js', new Date());
|
|
//REPLACE WITH YOUR GA TAG!
|
|
gtag('config', 'G-3Z83G8WLEK', { 'anonymize_ip': true, cookie_flags: 'secure;samesite=none' });
|
|
});
|
|
|
|
{{ end }}
|
|
} else if (readCookie('cookie-notice-option')!='false'){
|
|
deleteCookiesByPattern("_ga");
|
|
document.getElementById('cookie-notice').style.display = 'block';
|
|
} else if (readCookie('cookie-notice-option')=='false'){
|
|
deleteCookiesByPattern("_ga");
|
|
document.getElementById('cookie-notice').style.display = 'none';
|
|
}
|
|
|
|
document.getElementById('cookie-notice-accept').addEventListener("click",function() {
|
|
createCookie('cookie-notice-option','true',31);
|
|
console.log("Created Cookie!")
|
|
document.getElementById('cookie-notice').style.display = 'none';
|
|
location.reload();
|
|
});
|
|
|
|
document.getElementById('cookie-notice-deny').addEventListener("click",function() {
|
|
createCookie('cookie-notice-option','false',31);
|
|
document.getElementById('cookie-notice').style.display = 'none';
|
|
location.reload();
|
|
});
|
|
|
|
</script> |