mirror of
https://github.com/sartography/spiffworkflow_website.git
synced 2025-02-24 13:28:29 +00:00
87 lines
3.8 KiB
HTML
87 lines
3.8 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);
|
|
}
|
|
|
|
<!-- Google Tag Manager -->
|
|
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
|
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
|
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
|
})(window,document,'script','dataLayer','GTM-NFMNL96Z');
|
|
<!-- End Google Tag Manager -->
|
|
|
|
{{ 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> |