This commit is contained in:
Flatlogic Bot 2025-10-17 09:45:24 +00:00
parent 9a7532b7f7
commit 4ba12356e0

View File

@ -252,26 +252,32 @@ if (!$webinar) {
.then(data => { .then(data => {
if (data.success) { if (data.success) {
formContainer.style.display = 'none'; formContainer.style.display = 'none';
const webinarTitle = encodeURIComponent(data.webinar_title); const webinarTitle = encodeURIComponent(data.webinar_title);
const webinarDate = new Date(data.webinar_date_utc + 'Z'); const webinarDate = new Date(data.webinar_date_utc + 'Z');
const startTime = webinarDate.toISOString().replace(/-|:|..*Z/g, '') + 'Z';
const endTime = new Date(webinarDate.getTime() + (60 * 60 * 1000)).toISOString().replace(/-|:|..*Z/g, '') + 'Z'; // Correctly format dates for UTC (YYYYMMDDTHHMMSSZ)
const formatUTCDate = (date) => {
return date.toISOString().replace(/\.\d{3}Z$/, 'Z').replace(/[-:]/g, '');
};
const googleLink = `https://www.google.com/calendar/render?action=TEMPLATE&text=${webinarTitle}&dates=${startTime.replace(/Z$/, '')}/${endTime.replace(/Z$/, '')}&details=Join+the+webinar!`; const startTime = formatUTCDate(webinarDate);
const endTime = formatUTCDate(new Date(webinarDate.getTime() + (60 * 60 * 1000)));
const googleLink = `https://www.google.com/calendar/render?action=TEMPLATE&text=${webinarTitle}&dates=${startTime}/${endTime}&details=Join+the+webinar!&ctz=UTC`;
const icsContent = [ const icsContent = [
'BEGIN:VCALENDAR', 'BEGIN:VCALENDAR',
'VERSION:2.0', 'VERSION:2.0',
'BEGIN:VEVENT', 'BEGIN:VEVENT',
`URL:${window.location.href}`, `URL:${window.location.href}`,
`DTSTART:${startTime.replace(/Z$/, '')}`, `DTSTART:${startTime}`,
`DTEND:${endTime.replace(/Z$/, '')}`, `DTEND:${endTime}`,
`SUMMARY:${data.webinar_title}`, `SUMMARY:${data.webinar_title}`,
'DESCRIPTION:Join the webinar!', 'DESCRIPTION:Join the webinar!',
'END:VEVENT', 'END:VEVENT',
'END:VCALENDAR' 'END:VCALENDAR'
].join('\n'); ].join('\n');
const outlookLink = `data:text/calendar;charset=utf8,${encodeURIComponent(icsContent)}`; const outlookLink = `data:text/calendar;charset=utf-8,${encodeURIComponent(icsContent)}`;
formResult.innerHTML = ` formResult.innerHTML = `
<div class="success-message"> <div class="success-message">