add-to-calendar-button 1.6.3 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@
3
3
  * Add-to-Calendar Button
4
4
  * ++++++++++++++++++++++
5
5
  *
6
- * Version: 1.6.3
6
+ * Version: 1.6.4
7
7
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
8
8
  * Project: https://github.com/jekuer/add-to-calendar-button
9
9
  * License: MIT with “Commons Clause” License Condition v1.0
@@ -3,7 +3,7 @@
3
3
  * Add-to-Calendar Button
4
4
  * ++++++++++++++++++++++
5
5
  */
6
- const atcbVersion = '1.6.3';
6
+ const atcbVersion = '1.6.4';
7
7
  /* Creator: Jens Kuerschner (https://jenskuerschner.de)
8
8
  * Project: https://github.com/jekuer/add-to-calendar-button
9
9
  * License: MIT with “Commons Clause” License Condition v1.0
@@ -256,9 +256,11 @@ function atcb_generate(button, buttonId, data) {
256
256
  }
257
257
  });
258
258
  // standardize any line breaks in the description and transform URLs (but keep a clean copy without the URL magic for iCal)
259
- data['description'] = data['description'].replace(/<br\s*\/?>/gmi, '\n');
260
- data['description_iCal'] = data['description'].replace('[url]','').replace('[/url]','');
261
- data['description'] = data['description'].replace(/\[url\](.*?)\[\/url\]/g, "<a href='$1' target='_blank' rel='noopener'>$1</a>");
259
+ if (data['description'] != null) {
260
+ data['description'] = data['description'].replace(/<br\s*\/?>/gmi, '\n');
261
+ data['description_iCal'] = data['description'].replace('[url]','').replace('[/url]','');
262
+ data['description'] = data['description'].replace(/\[url\](.*?)\[\/url\]/g, "<a href='$1' target='_blank' rel='noopener'>$1</a>");
263
+ }
262
264
  // generate the options list
263
265
  let optionsList = document.createElement('div');
264
266
  optionsList.id = 'atcb_list_' + buttonId;
@@ -535,15 +537,21 @@ function atcb_generate_ical(data) {
535
537
  "DTSTAMP:" + formattedDate['start'],
536
538
  "DTSTART" + timeslot + ":" + formattedDate['start'],
537
539
  "DTEND" + timeslot + ":" + formattedDate['end'],
538
- "DESCRIPTION:" + data['description_iCal'].replace(/\n/g, '\\n'),
539
- "SUMMARY:" + data['name'],
540
- "LOCATION:" + data['location'],
540
+ "SUMMARY:" + data['name']
541
+ ];
542
+ if (data['description_iCal'] != null && data['description_iCal'] != '') {
543
+ ics_lines.push("DESCRIPTION:" + data['description_iCal'].replace(/\n/g, '\\n'));
544
+ }
545
+ if (data['location'] != null && data['location'] != '') {
546
+ ics_lines.push("LOCATION:" + data['location']);
547
+ }
548
+ ics_lines.push(
541
549
  "STATUS:CONFIRMED",
542
550
  "LAST-MODIFIED:" + now,
543
551
  "SEQUENCE:0",
544
552
  "END:VEVENT",
545
553
  "END:VCALENDAR"
546
- ];
554
+ );
547
555
  let dlurl = 'data:text/calendar;charset=utf-8,'+encodeURIComponent(ics_lines.join('\r\n'));
548
556
  try {
549
557
  if (!window.ActiveXObject) {
@@ -3,7 +3,7 @@
3
3
  * Add-to-Calendar Button
4
4
  * ++++++++++++++++++++++
5
5
  */
6
- const atcbVersion = '1.6.3';
6
+ const atcbVersion = '1.6.4';
7
7
  /* Creator: Jens Kuerschner (https://jenskuerschner.de)
8
8
  * Project: https://github.com/jekuer/add-to-calendar-button
9
9
  * License: MIT with “Commons Clause” License Condition v1.0
@@ -256,9 +256,11 @@ function atcb_generate(button, buttonId, data) {
256
256
  }
257
257
  });
258
258
  // standardize any line breaks in the description and transform URLs (but keep a clean copy without the URL magic for iCal)
259
- data['description'] = data['description'].replace(/<br\s*\/?>/gmi, '\n');
260
- data['description_iCal'] = data['description'].replace('[url]','').replace('[/url]','');
261
- data['description'] = data['description'].replace(/\[url\](.*?)\[\/url\]/g, "<a href='$1' target='_blank' rel='noopener'>$1</a>");
259
+ if (data['description'] != null) {
260
+ data['description'] = data['description'].replace(/<br\s*\/?>/gmi, '\n');
261
+ data['description_iCal'] = data['description'].replace('[url]','').replace('[/url]','');
262
+ data['description'] = data['description'].replace(/\[url\](.*?)\[\/url\]/g, "<a href='$1' target='_blank' rel='noopener'>$1</a>");
263
+ }
262
264
  // generate the options list
263
265
  let optionsList = document.createElement('div');
264
266
  optionsList.id = 'atcb_list_' + buttonId;
@@ -535,15 +537,21 @@ function atcb_generate_ical(data) {
535
537
  "DTSTAMP:" + formattedDate['start'],
536
538
  "DTSTART" + timeslot + ":" + formattedDate['start'],
537
539
  "DTEND" + timeslot + ":" + formattedDate['end'],
538
- "DESCRIPTION:" + data['description_iCal'].replace(/\n/g, '\\n'),
539
- "SUMMARY:" + data['name'],
540
- "LOCATION:" + data['location'],
540
+ "SUMMARY:" + data['name']
541
+ ];
542
+ if (data['description_iCal'] != null && data['description_iCal'] != '') {
543
+ ics_lines.push("DESCRIPTION:" + data['description_iCal'].replace(/\n/g, '\\n'));
544
+ }
545
+ if (data['location'] != null && data['location'] != '') {
546
+ ics_lines.push("LOCATION:" + data['location']);
547
+ }
548
+ ics_lines.push(
541
549
  "STATUS:CONFIRMED",
542
550
  "LAST-MODIFIED:" + now,
543
551
  "SEQUENCE:0",
544
552
  "END:VEVENT",
545
553
  "END:VCALENDAR"
546
- ];
554
+ );
547
555
  let dlurl = 'data:text/calendar;charset=utf-8,'+encodeURIComponent(ics_lines.join('\r\n'));
548
556
  try {
549
557
  if (!window.ActiveXObject) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "add-to-calendar-button",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
4
4
  "description": "A convenient JavaScript snippet, which lets you create beautiful buttons, where people can add events to their calendars.",
5
5
  "main": "npm_dist/cjs/index.js",
6
6
  "module": "npm_dist/mjs/index.js",