var user = {};
var params = new URLSearchParams(window.location.search);
var path = window.location.pathname;
const userPictures = document.getElementsByClassName('user-picture');
const signupCTAs = document.getElementsByClassName('get-started');
const bookDemoCTAs = document.querySelectorAll('[href*="request-demo"]');
const isSignedIn = document.getElementsByClassName('is-user-state');
const isSignedInInline = document.getElementsByClassName('is-state-user-inline');
const upgradeCTAs = document.getElementsByClassName('button-pricing-plan');
const educationCTAs = document.getElementsByClassName('gmelius-university');
try {
window.onload = function() {
document.getElementById('dashboard-frame-app').src = 'https://app.gmelius.com/websiteProxy.html';
};
window.addEventListener('message', function (e) {
if (e.origin === 'https://app.gmelius.com') {
user = e.data;
window.localStorage.setItem('user', JSON.stringify(user));
}
});
if (!Object.keys(user).length && window.localStorage.getItem('user')) {
user = JSON.parse(window.localStorage.getItem('user'));
}
if (!Object.keys(user).length && (params.has('ref') && (params.get('ref') === 'dashboard' || params.get('ref') === 'extension'))) {
user.picture = 'https://cloud.gmelius.com/public/logos/gmelius-32.png';
window.localStorage.setItem('user', JSON.stringify(user));
}
if (Object.keys(user).length) {
if (userPictures.length > 0) {
Array.from(userPictures).forEach(function(picture) {
if (user.email) {
picture.src = user.picture || `https://avatar.oxro.io/avatar.svg?name=${user.email.toUpperCase()}&length=1`;
} else {
picture.src = 'https://cloud.gmelius.com/public/images/avatar-astro.png'
}
picture.onerror = function () {
this.style.display = 'none';
}
});
}
if (signupCTAs.length > 0) {
Array.from(signupCTAs).forEach(function(cta) {
//cta.style.display = 'none';
});
}
if (isSignedIn.length > 0) {
Array.from(isSignedIn).forEach(function(cta) {
//cta.style.display = 'none';
});
}
if (isSignedInInline.length > 0) {
Array.from(isSignedInInline).forEach(function(cta) {
//cta.style.display = 'inline';
});
}
if (educationCTAs.length > 0) {
document.body.classList.add('hasAnnouncement');
Array.from(educationCTAs).forEach(function(cta) {
cta.style.display = 'block';
});
}
if (upgradeCTAs.length > 0) {
Array.from(upgradeCTAs).forEach(function(cta) {
cta.classList.add('upgrade');
});
}
}
} catch (e) {}
// Beamer
var beamer_config = {
product_id : 'CIJpSEcT13796', //DO NOT CHANGE: This is your product code on Beamer
selector : '.beamer-widget', /*Optional: Id, class (or list of both) of the HTML element to use as a button*/
//display : 'right', /*Optional: Choose how to display the Beamer panel in your site*/
top: 10, /*Optional: Top position offset for the notification bubble*/
//right: -10, /*Optional: Right position offset for the notification bubble*/
//bottom: 0, /*Optional: Bottom position offset for the notification bubble*/
left: 30, /*Optional: Left position offset for the notification bubble*/
//button_position: 'bottom-right', /*Optional: Position for the notification button that shows up when the selector parameter is not set*/
//icon: 'bell_lines', /*Optional: Alternative icon to display in the notification button*/
//language: 'EN', /*Optional: Bring news in the language of choice*/
//filter: 'admin', /*Optional : Bring the news for a certain role as well as all the public news*/
//lazy: false, /*Optional : true if you want to manually start the script by calling Beamer.init()*/
//alert : true, /*Optional : false if you don't want to initialize the selector*/
//delay : 0, /*Optional : Delay (in milliseconds) before initializing Beamer*/
//embed : false, /*Optional : true if you want to embed and display the feed inside the element selected by the 'selector' parameter*/
//mobile : true, /*Optional : false if you don't want to initialize Beamer on mobile devices*/
//notification_prompt : 'sidebar', /*Optional : override the method selected to prompt users for permission to receive web push notifications*/
//callback : your_callback_function, /*Optional : Beamer will call this function, with the number of new features as a parameter, after the initialization*/
//onclick : your_onclick_function(url, openInNewWindow), /*Optional : Beamer will call this function when a user clicks on a link in one of your posts*/
//onopen : your_onopen_function, /*Optional : Beamer will call this function when opening the panel*/
//onclose : your_onclose_function, /*Optional : Beamer will call this function when closing the panel*/
//---------------Visitor Information---------------
//user_firstname : "firstname", /*Optional : Input your user firstname for better statistics*/
//user_lastname : "lastname", /*Optional : Input your user lastname for better statistics*/
user_email : user.email ? user.email : null, /*Optional : Input your user email for better statistics*/
//user_id : "user_id" /*Optional : Input your user ID for better statistics*/
};
document.addEventListener('DOMContentLoaded', function () {
if (user && user.email) {
$crisp.push(["set", "user:email", [user.email]]);
}
const talkToSalesBtn = document.getElementById('talk-to-sales');
const tryProBtn = document.getElementById('try-pro');
// Wait until Crisp is fully loaded
function waitForCrisp(callback, attempts = 0) {
if (window.$crisp && window.$crisp.is && window.CRISP_WEBSITE_ID) {
callback();
} else if (attempts < 10) { // retry up to 10 times (5 sec)
setTimeout(() => waitForCrisp(callback, attempts + 1), 500);
} else {
console.error('Crisp SDK failed to load.');
}
}
function sendVisitorMessage(messageText) {
$crisp.push(["set", "message:text", [messageText]]);
}
// Open Crisp chat and display messages
function openChatAndShowMessages(data) {
if (!$crisp.is("chat:visible")) {
$crisp.push(["do", "chat:show"]);
}
if (!$crisp.is("chat:opened")) {
$crisp.push(["do", "chat:open"]);
}
const messageCrisp = (data === "enterprise") ? "Hi, I'd like to talk to your Enterprise Sales Team. My company name is: " : "Hi, I'd like to start a trial of Gmelius Pro. My email address is:";
// Small delay ensures Crisp DOM readiness
setTimeout(() => {
sendVisitorMessage(messageCrisp);
}, 500);
}
// Button click handler
talkToSalesBtn.addEventListener('click', function (event) {
event.preventDefault();
waitForCrisp(() => openChatAndShowMessages('enterprise'));
});
tryProBtn.addEventListener('click', function (event) {
event.preventDefault();
waitForCrisp(() => openChatAndShowMessages('try-pro'));
});
});
-->