$(document).ready(()=>{
const baseUrl = `http://${window.location.hostname}`;
const content = $('.content');
const urlString = window.location.href;
const url = new URL(urlString);
const sid = url.searchParams.get("sid");
$.getJSON( baseUrl + "/apis/getMessages.php", {
sid: sid
}).done( (session)=> {
console.log(session);
if(session.enabled){
$.each(session.messages, (index,item)=>{
if(item.timer != session.start){
const now = new Date().getTime();
const timerValue = item.timer.split(' ');
const timerDate = timerValue[0].split('-');
const timerHours = timerValue[1].split(':');
const timer = new Date(timerDate[0], timerDate[1] - 1, timerDate[2], timerHours[0], timerHours[1], timerHours[2]).getTime();
const startValue = session.start.split(' ');
const startDate = startValue[0].split('-');
const startHours = startValue[1].split(':');
const start = new Date(startDate[0], startDate[1] - 1, startDate[2], startHours[0], startHours[1], startHours[2]).getTime();
if(now > timer){
showCloud(item.title, [item.short_text, item.long_text], item.image, item.actions, session.messages);
notify(true);
} else {
const delay = (timer - now);
setTimeout( ()=>{
showCloud(item.title, [item.short_text, item.long_text], item.image, item.actions, session.messages);
notify(true);
},delay);
}
}
});
}
});
function showCloud(title, text, img, actions, messages){
const image = img ? `