/home2/mshostin/public_html/assets/calendar.html
<!-- <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Create ICS File</title>
    <style>
        #download-ics {
            border: none;
            background-color: transparent;
            color: rgb(3, 3, 5);
            text-decoration: underline;
            cursor: pointer;
            font-size: 16px; /* Adjust the font size as needed */
        }
        #download-ics:focus {
            outline: none; /* Remove the focus outline */
        }
    </style>
</head>
<body>
    <h1>Create ICS File with Hyperlink</h1>
    <button id="download-ics">Download ICS</button>

    <script>
        document.getElementById('download-ics').addEventListener('click', function () {
            // ICS file content
            const icsContent = `
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Your Company//Your Product//EN
BEGIN:VEVENT
UID:1234567890
DTSTAMP:20240628T090000Z
DTSTART:20240701T090000Z
DTEND:20240701T100000Z
SUMMARY:Sample Event
DESCRIPTION:This is a sample event. For more info, visit <a href="https://www.example.com">Example Website</a>
LOCATION:Online
END:VEVENT
SEQUENCE:1
END:VCALENDAR`;

            // Create a blob with the ics content
            const blob = new Blob([icsContent], { type: 'text/calendar' });

            // Create a link element
            const link = document.createElement('a');
            link.href = URL.createObjectURL(blob);
            link.download = 'event.ics';

            // Append the link to the body
            document.body.appendChild(link);

            // Simulate a click on the link
            link.click();

            // Remove the link from the document
            document.body.removeChild(link);
        });
    </script>
</body>
</html> -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Create ICS File</title>
</head>
<body>
    <h1>Create ICS File with Hyperlink</h1>
    <button id="download-ics" style="display: none;">Download ICS</button> <!-- Hidden button -->

    <script>
        // Function to get URL parameters
        function getURLParams() {
            const params = new URLSearchParams(window.location.search);
            return {
                uid: params.get('uid') || '1234567890',
                dtstamp: params.get('dtstamp') || '20240628T090000Z',
                dtstart: params.get('dtstart') || '20240701T090000Z',
                dtend: params.get('dtend') || '20240701T100000Z',
                summary: params.get('summary') || 'Sample Event',
                description: params.get('description') || 'This is a sample event. For more info, visit <a href="https://www.example.com">Example Website</a>',
                location: params.get('location') || 'Online'
            };
        }

        function downloadICS() {
            const params = getURLParams();

            // ICS file content with dynamic values
       
  
   const icsContent = `BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Your Company//Your Product//EN
BEGIN:VEVENT
UID:${params.uid}
DTSTAMP:${params.dtstamp}
DTSTART:${params.dtstart}
DTEND:${params.dtend}
SUMMARY:${params.summary}
DESCRIPTION:${params.description}
LOCATION:${params.location}
SEQUENCE:1
END:VEVENT
END:VCALENDAR`;

            // Create a blob with the ics content
            const blob = new Blob([icsContent], { type: 'text/calendar' });

   const now = new Date();
    const year = now.getFullYear();
    const month = String(now.getMonth() + 1).padStart(2, '0');
    const day = String(now.getDate()).padStart(2, '0');
    const hours = String(now.getHours()).padStart(2, '0');
    const minutes = String(now.getMinutes()).padStart(2, '0');
    const seconds = String(now.getSeconds()).padStart(2, '0');
    const filename = `event_${year}${month}${day}_${hours}${minutes}${seconds}.ics`;

            // Create a link element
            const link = document.createElement('a');
            link.href = URL.createObjectURL(blob);
              link.download = filename;


            // Append the link to the body
            document.body.appendChild(link);

            // Simulate a click on the link
            link.click();

            // Remove the link from the document
            document.body.removeChild(link);
        }

        // Execute download and close window on page load
        window.onload = function() {
            downloadICS();
            setTimeout(() => {
                window.close();
            }, 2000); 
        };
    </script>
</body>
</html>