mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-03 09:58:30 +02:00
initial commit for segment introduction (#998)
* initial commit for segment introduction * conditionals to check for window.analytics
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { getCookie, setCookie } from './helpers';
|
||||
import { loadSegment, handleConsent } from './segment-helpers';
|
||||
|
||||
(function () {
|
||||
window.cookit = function (options) {
|
||||
// SETTINGS
|
||||
@@ -56,32 +59,13 @@
|
||||
|
||||
// EVENT LISTENER (click)
|
||||
button.addEventListener('click', () => {
|
||||
if (!window.analytics) {
|
||||
loadSegment();
|
||||
handleConsent();
|
||||
}
|
||||
|
||||
banner.remove();
|
||||
setCookie('cookie-consent', 1, settings.lifetime);
|
||||
});
|
||||
|
||||
// GET COOKIE
|
||||
function getCookie(name) {
|
||||
const decodedCookie = decodeURIComponent(document.cookie);
|
||||
const ca = decodedCookie.split(';');
|
||||
name = name + '=';
|
||||
for (let i = 0; i < ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
if (c.indexOf(name) === 0) {
|
||||
return c.substring(name.length, c.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SET COOKIE
|
||||
function setCookie(name, value, days) {
|
||||
const date = new Date();
|
||||
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
||||
const expires = 'expires=' + date.toUTCString();
|
||||
document.cookie = name + '=' + value + ';' + expires + ';path=/;Secure';
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user