admin
Web-platform for administrating communities in Qela
let gtmLoaded = false;
const loadGTM = function (){
if (gtmLoaded) return;
gtmLoaded = true;
const gtmScript = document.createElement("script");
gtmScript.innerHTML = `
(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-N3HHLKXS');
`;
document.head.appendChild(gtmScript);
const iframe = document.createElement("iframe");
iframe.src = "https://www.googletagmanager.com/ns.html?id=GTM-N3HHLKXS";
iframe.height = "0";
iframe.width = "0";
iframe.style.display = "none";
iframe.style.visibility = "hidden";
document.body.appendChild(iframe);
};
const setCookie = function (name, value, days) {
const d = new Date();
d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000));
document.cookie = `${name}=${value}; expires=${d.toUTCString()}; path=/`;
};
const getCookie = function(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
};
const acceptCookies = function () {
setCookie("cookieNoticeAccepted", "true", 365);
loadGTM();
};
const rejectCookies = function () {
setCookie("cookieNoticeAccepted", "false", 365);
};
window.onload = function () {
const cookieConsent = getCookie("cookieNoticeAccepted");
if (cookieConsent === "true") {
loadGTM();
} else if (cookieConsent !== "false") {
document.getElementById("cookie-banner").classList.add("show");
}
};