Skip to content

Commit

Permalink
Deploying to gh-pages from @ 56a36a9 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Aug 31, 2023
1 parent e29969f commit 23050f1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 131 deletions.
129 changes: 0 additions & 129 deletions js/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -180414,132 +180414,3 @@ var mindmapDefinition65b51176 = /*#__PURE__*/Object.freeze({
__proto__: null,
diagram: diagram
});


//the following is made by CMR
/**
* Create and download a file on click
* @params {string} filename - The name of the file with the ending
* @params {string} filebody - The contents of the file
*/
function download(filename, fileBody) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(fileBody));
element.setAttribute('download', filename);

element.style.display = 'none';
document.body.appendChild(element);

element.click();

document.body.removeChild(element);
}


/**
* Returns a date/time in ICS format
* @params {Object} dateTime - A date object you want to get the ICS format for.
* @returns {string} String with the date in ICS format
*/
function convertToICSDate(dateTime) {
const year = dateTime.getFullYear().toString();
const month = (dateTime.getMonth() + 1) < 10 ? "0" + (dateTime.getMonth() + 1).toString() : (dateTime.getMonth() + 1).toString();
const day = dateTime.getDate() < 10 ? "0" + dateTime.getDate().toString() : dateTime.getDate().toString();
const hours = dateTime.getHours() < 10 ? "0" + dateTime.getHours().toString() : dateTime.getHours().toString();
const minutes = dateTime.getMinutes() < 10 ? "0" +dateTime.getMinutes().toString() : dateTime.getMinutes().toString();

return year + month + day + "T" + hours + minutes + "00";
}


/**
* Creates and downloads an ICS file
* @params {string} timeZone - In the format Berlin/Germany
* @params {object} startTime - Vaild JS Date object in the event timezone
* @params {object} endTime - Vaild JS Date object in the event timezone
* @params {string} title
* @params {string} description
* @params {string} venueName
* @params {string} address
* @params {string} city
* @params {string} state
* @params {string} category
*/
function createDownloadICSFile(timezone, startTime, endTime, title, description, venueName, address, city, state, category) {
const icsBody = 'BEGIN:VCALENDAR\n' +
'VERSION:2.0\n' +
'PRODID:DataPLANT\n' +
'CALSCALE:GREGORIAN\n' +
'METHOD:PUBLISH\n' +
'BEGIN:VTIMEZONE\n' +
'TZID:Europe/Berlin\n' +
'X-LIC-LOCATION:Europe/Berlin\n' +
'BEGIN:DAYLIGHT\n' +
'TZOFFSETFROM:+0100\n' +
'TZOFFSETTO:+0200\n' +
'TZNAME:CEST\n' +
'DTSTART:20020331T020000\n' +
'RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\n' +
'END:DAYLIGHT\n' +
'BEGIN:STANDARD\n' +
'TZOFFSETFROM:+0200\n' +
'TZOFFSETTO:+0100\n' +
'TZNAME:CET\n' +
'DTSTART:20021027T030000\n' +
'RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\n' +
'END:STANDARD\n' +
'END:VTIMEZONE\n' +
'BEGIN:VEVENT\n' +
'SUMMARY:' + title + '\n' +
'UID:@Default\n' +
'SEQUENCE:0\n' +
'STATUS:CONFIRMED\n' +
'TRANSP:TRANSPARENT\n' +
'DTSTART;TZID=' + timezone + ':' + convertToICSDate(startTime) + '\n' +
'DTEND;TZID=' + timezone + ':' + convertToICSDate(endTime)+ '\n' +
'DTSTAMP:'+ convertToICSDate(new Date()) + '\n' +
'LOCATION:' + venueName + '\\n' + address + ', ' + city + ', ' + state + '\n' +
'DESCRIPTION:' + description + '\n' +
'CATEGORIES:' + category + '\n' +
'X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n' +
'X-MICROSOFT-CDO-IMPORTANCE:1\n' +
'X-MICROSOFT-DISALLOW-COUNTER:FALSE\n' +
'BEGIN:VALARM\n' +
'TRIGGER:-PT15M\n' +
'ACTION:DISPLAY\n' +
'DESCRIPTION:Reminder\n' +
'END:VALARM\n' +
'END:VEVENT\n' +
'END:VCALENDAR\n';

download(title + '.ics', icsBody);
}


var downloadICSButton = document.getElementById('downloadICS');

downloadICSButton.addEventListener('click', function() {
// Die gewünschten Werte aus dem HTML-Element abrufen
var title = this.getAttribute('title');
var startTime = new Date(this.getAttribute('data-start-time'));
var endTime = new Date(this.getAttribute('data-end-time'));
var description = this.getAttribute('data-description');
var venueName = this.getAttribute('data-venue-name');
var address = this.getAttribute('data-address');
var city = this.getAttribute('data-city');
var state = this.getAttribute('data-state');
var category = this.getAttribute('data-category');

createDownloadICSFile(
'Europe/Berlin',
startTime,
endTime,
title,
description,
venueName,
address,
city,
state,
category
);
});
2 changes: 1 addition & 1 deletion style/constants.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion style/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 23050f1

Please sign in to comment.