add-to-calendar-button 1.4.3 → 1.6.0

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.
package/README.md CHANGED
@@ -38,7 +38,7 @@ See [jekuer.github.io/add-to-calendar-button](https://jekuer.github.io/add-to-ca
38
38
  * Up-to-date integration of all popular calendars:
39
39
  * Google Calendar.
40
40
  * Yahoo Calender.
41
- * Microsoft 365 (and Outlook).
41
+ * Microsoft 365, Outlook, and Teams.
42
42
  * Automatically generated iCal/ics files (for all other calendars, like Apple).
43
43
  * Timed and all-day events.
44
44
  * Translatable labels and dynamic.
@@ -88,8 +88,8 @@ Mind that with Angular, you might need to escape the { with `{{ '{' }}` and } wi
88
88
  <div class="atcb" style="display:none;">
89
89
  {
90
90
  "name":"Add the title of your event",
91
- "startDate":"02-21-2022",
92
- "endDate":"03-24-2022",
91
+ "startDate":"2022-02-21",
92
+ "endDate":"2022-03-24",
93
93
  "options":[
94
94
  "Google"
95
95
  ]
@@ -104,8 +104,8 @@ Mind that with Angular, you might need to escape the { with `{{ '{' }}` and } wi
104
104
  {
105
105
  "name":"Add the title of your event",
106
106
  "description":"A nice description does not hurt",
107
- "startDate":"02-21-2022",
108
- "endDate":"03-24-2022",
107
+ "startDate":"2022-02-21",
108
+ "endDate":"2022-03-24",
109
109
  "startTime":"10:13",
110
110
  "endTime":"17:57",
111
111
  "location":"Somewhere over the rainbow",
@@ -115,6 +115,7 @@ Mind that with Angular, you might need to escape the { with `{{ '{' }}` and } wi
115
115
  "Google",
116
116
  "iCal",
117
117
  "Microsoft365",
118
+ "MicrosoftTeams",
118
119
  "Outlook.com",
119
120
  "Yahoo"
120
121
  ],
@@ -139,8 +140,8 @@ You can use startTime and endTime in the event block, but it is recommended to r
139
140
  "@type":"Event",
140
141
  "name":"Add the title of your event",
141
142
  "description":"A nice description does not hurt",
142
- "startDate":"02-21-2022T10:13",
143
- "endDate":"03-24-2022T17:57",
143
+ "startDate":"2022-02-21T10:13",
144
+ "endDate":"2022-03-24T17:57",
144
145
  "location":"Somewhere over the rainbow"
145
146
  },
146
147
  "label":"Add to Calendar",
@@ -149,6 +150,7 @@ You can use startTime and endTime in the event block, but it is recommended to r
149
150
  "Google",
150
151
  "iCal",
151
152
  "Microsoft365",
153
+ "MicrosoftTeams",
152
154
  "Outlook.com",
153
155
  "Yahoo"
154
156
  ],
@@ -186,9 +188,9 @@ const AddToCalendar = () => {
186
188
  ### Important information and hidden features
187
189
 
188
190
  * The "label" is optional, but enables you to customize the button text. Default: "Add to Calendar".
189
- * Dates need to be formatted as MM-DD-YYYY.
191
+ * Dates need to be formatted as YYYY-MM-DD ([ISO-8601](https://en.wikipedia.org/wiki/ISO_8601)).
190
192
  * You can also use the word "today" as date. It will then dynamically use the current day at click.
191
- * Add "+5" at the end of the date to dynamically add 5 days (or any other number). "01-30-2022+12" would generate the 11th of February 2022. This can be interesting, when combined with "today".
193
+ * Add "+5" at the end of the date to dynamically add 5 days (or any other number). "2022-01-30+12" would generate the 11th of February 2022. This can be interesting, when combined with "today".
192
194
  * Times need to be formatted as HH:MM.
193
195
  * Times are optional. If not set, the button generates all-day events.
194
196
  * 1 option is required. You can add as many as you want. The supported formats are listed above.
@@ -202,6 +204,7 @@ const AddToCalendar = () => {
202
204
  * You can set the trigger to "click". This makes the button open on click at desktop. Otherwise, the default would be to open on hover. On touch devices, this makes no difference.
203
205
  * If you want to define a specific name for any generated ics file (iCal), you can specify it via the "iCalFileName" option. The default would be "event-to-save-in-my-calendar".
204
206
  * You can use the option "inline":true in order to make the button appear with inline-block instead of block style.
207
+ * Formatting a URL in the description like `[url]https://....[/url]` makes it clickable.
205
208
  * If you require line breaks within the description, use `\n` or `<br>`.
206
209
 
207
210
 
@@ -223,6 +226,8 @@ The code is available under the [MIT license (with “Commons Clause” License
223
226
 
224
227
  ## Changelog (without bug fixes)
225
228
 
229
+ * v1.6 : supporting Microsoft Teams
230
+ * v1.5 : update to date format and better accesibility
226
231
  * v1.4 : schema.org support (also changed some keys in the JSON!)
227
232
  * v1.3 : new license (MIT with “Commons Clause”)
228
233
  * v1.2 : inline and line break support
@@ -233,3 +238,4 @@ The code is available under the [MIT license (with “Commons Clause” License
233
238
  ## Kudos go to
234
239
  * [github.com/dudewheresmycode](https://github.com/dudewheresmycodee)
235
240
  * [uxwing.com](https://uxwing.com)
241
+ * all contributors!
@@ -3,7 +3,7 @@
3
3
  * Add-to-Calendar Button
4
4
  * ++++++++++++++++++++++
5
5
  *
6
- * Version: 1.4.3
6
+ * Version: 1.6.0
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
@@ -45,6 +45,9 @@
45
45
  -webkit-tap-highlight-color: transparent;
46
46
  width: auto;
47
47
  }
48
+ .atcb_button:hover {
49
+ background: rgb(255, 255, 255);
50
+ }
48
51
  @media only screen and (max-width: 575px) {
49
52
  .atcb_button {
50
53
  font-size: 14px;
@@ -1,2 +1,2 @@
1
- .atcb{display:none}.atcb_button_wrapper{display:inline-block;position:relative}.atcb_button{background:#f5f5f5;border:1px solid #d2d2d2;border-radius:6px;-webkit-box-shadow:1px 2px 10px 0 rgba(0,0,0,.4);box-shadow:1px 2px 10px 0 rgba(0,0,0,.4);color:#333;cursor:pointer;display:inline-block;font-size:16px;font-weight:600;line-height:24px;margin:10px auto;max-width:300px;min-width:150px;padding:10px 16px 11px 16px;position:relative;text-align:center;touch-action:manipulation;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;width:auto}@media only screen and (max-width:575px){.atcb_button{font-size:14px}}.atcb_button.active{background:#fff;border-radius:6px 6px 3px 3px;-webkit-box-shadow:1px 5px 15px 0 rgba(0,0,0,.5);box-shadow:1px 5px 15px 0 rgba(0,0,0,.5);margin:7px auto 9px auto;padding:12px 20px 13px 20px;z-index:90}.atcb_icon{height:16px;display:inline-flex;margin-bottom:4px;margin-right:10px;vertical-align:middle}.atcb_icon svg{height:100%;color:#333;width:auto}.atcb_list{box-sizing:border-box;color:#333;display:block;margin:-10px auto 0 auto;max-width:100%;position:absolute;padding:0 3px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:100%;z-index:80}.atcb_list_item{background:#fafafa;border:1px solid #d2d2d2;border-top:0;-webkit-box-shadow:1px 2px 8px 0 rgba(0,0,0,.3);box-shadow:1px 2px 8px 0 rgba(0,0,0,.3);box-sizing:border-box;cursor:pointer;font-size:16px;left:50%;position:relative;padding:12px 18px;text-align:left;transform:translate(-50%);touch-action:manipulation;-webkit-tap-highlight-color:transparent}.atcb_list_item:hover{background:#fff;-webkit-box-shadow:1px 2px 10px 0 rgba(0,0,0,.4);box-shadow:1px 2px 10px 0 rgba(0,0,0,.4);color:#000}@media only screen and (max-width:575px){.atcb_list_item{font-size:14px}}.atcb_list_item:first-child{padding-top:25px}.atcb_list_item:last-child{border-radius:0 0 6px 6px}.atcb_list_item .atcb_icon{margin-right:8px}.atcb_bgoverlay{background:rgba(20,20,20,.2);backdrop-filter:blur(2px);height:100%;left:0;position:fixed;top:0;width:100%;z-index:70}
1
+ .atcb{display:none}.atcb_button_wrapper{display:inline-block;position:relative}.atcb_button{background:#f5f5f5;border:1px solid #d2d2d2;border-radius:6px;-webkit-box-shadow:1px 2px 10px 0 rgba(0,0,0,.4);box-shadow:1px 2px 10px 0 rgba(0,0,0,.4);color:#333;cursor:pointer;display:inline-block;font-size:16px;font-weight:600;line-height:24px;margin:10px auto;max-width:300px;min-width:150px;padding:10px 16px 11px 16px;position:relative;text-align:center;touch-action:manipulation;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;width:auto}.atcb_button:hover{background:#fff}@media only screen and (max-width:575px){.atcb_button{font-size:14px}}.atcb_button.active{background:#fff;border-radius:6px 6px 3px 3px;-webkit-box-shadow:1px 5px 15px 0 rgba(0,0,0,.5);box-shadow:1px 5px 15px 0 rgba(0,0,0,.5);margin:7px auto 9px auto;padding:12px 20px 13px 20px;z-index:90}.atcb_icon{height:16px;display:inline-flex;margin-bottom:4px;margin-right:10px;vertical-align:middle}.atcb_icon svg{height:100%;color:#333;width:auto}.atcb_list{box-sizing:border-box;color:#333;display:block;margin:-10px auto 0 auto;max-width:100%;position:absolute;padding:0 3px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:100%;z-index:80}.atcb_list_item{background:#fafafa;border:1px solid #d2d2d2;border-top:0;-webkit-box-shadow:1px 2px 8px 0 rgba(0,0,0,.3);box-shadow:1px 2px 8px 0 rgba(0,0,0,.3);box-sizing:border-box;cursor:pointer;font-size:16px;left:50%;position:relative;padding:12px 18px;text-align:left;transform:translate(-50%);touch-action:manipulation;-webkit-tap-highlight-color:transparent}.atcb_list_item:hover{background:#fff;-webkit-box-shadow:1px 2px 10px 0 rgba(0,0,0,.4);box-shadow:1px 2px 10px 0 rgba(0,0,0,.4);color:#000}@media only screen and (max-width:575px){.atcb_list_item{font-size:14px}}.atcb_list_item:first-child{padding-top:25px}.atcb_list_item:last-child{border-radius:0 0 6px 6px}.atcb_list_item .atcb_icon{margin-right:8px}.atcb_bgoverlay{background:rgba(20,20,20,.2);backdrop-filter:blur(2px);height:100%;left:0;position:fixed;top:0;width:100%;z-index:70}
2
2
  /*# sourceMappingURL=atcb.min.css.map */
@@ -1 +1 @@
1
- {"version":3,"sources":["assets\\css\\atcb.css"],"names":[],"mappings":"AAYA,MACE,QAAS,KAGX,qBACE,QAAS,aACT,SAAU,SAGZ,aACE,WAAY,QACZ,OAAQ,IAAI,MAAM,QAClB,cAAe,IACf,mBAAoB,IAAI,IAAI,KAAK,EAAI,eACrC,WAAY,IAAI,IAAI,KAAK,EAAI,eAC7B,MAAO,KACP,OAAQ,QACR,QAAS,aACT,UAAW,KACX,YAAa,IACb,YAAa,KACb,OAAQ,KAAK,KACb,UAAW,MACX,UAAW,MACX,QAAS,KAAK,KAAK,KAAK,KACxB,SAAU,SACV,WAAY,OACZ,aAAc,aACd,oBAAqB,KACrB,iBAAkB,KAClB,gBAAiB,KACjB,YAAa,KACb,4BAA6B,YAC7B,MAAO,KAET,yCACE,aACE,UAAW,MAIf,oBACE,WAAY,KACZ,cAAe,IAAI,IAAI,IAAI,IAC3B,mBAAoB,IAAI,IAAI,KAAK,EAAI,eACrC,WAAY,IAAI,IAAI,KAAK,EAAI,eAC7B,OAAQ,IAAI,KAAK,IAAI,KACrB,QAAS,KAAK,KAAK,KAAK,KACxB,QAAS,GAGX,WACE,OAAQ,KACR,QAAS,YACT,cAAe,IACf,aAAc,KACd,eAAgB,OAElB,eACE,OAAQ,KACR,MAAO,KACP,MAAO,KAGT,WACE,WAAY,WACZ,MAAO,KACP,QAAS,MACT,OAAQ,MAAM,KAAK,EAAE,KACrB,UAAW,KACX,SAAU,SACV,QAAS,EAAE,IACX,oBAAqB,KACrB,iBAAkB,KAClB,gBAAiB,KACjB,YAAa,KACb,MAAO,KACP,QAAS,GAGX,gBACE,WAAY,QACZ,OAAQ,IAAI,MAAM,QAClB,WAAY,EACZ,mBAAoB,IAAI,IAAI,IAAI,EAAI,eACpC,WAAY,IAAI,IAAI,IAAI,EAAI,eAC5B,WAAY,WACZ,OAAQ,QACR,UAAW,KACX,KAAM,IACN,SAAU,SACV,QAAS,KAAK,KACd,WAAY,KACZ,UAAW,gBACX,aAAc,aACd,4BAA6B,YAE/B,sBACE,WAAY,KACZ,mBAAoB,IAAI,IAAI,KAAK,EAAI,eACrC,WAAY,IAAI,IAAI,KAAK,EAAI,eAC7B,MAAO,KAET,yCACE,gBACE,UAAW,MAIf,4BACE,YAAa,KAGf,2BACE,cAAe,EAAE,EAAE,IAAI,IAIzB,2BACE,aAAc,IAGhB,gBACE,WAAY,kBACZ,gBAAiB,UACjB,OAAQ,KACR,KAAM,EACN,SAAU,MACV,IAAK,EACL,MAAO,KACP,QAAS"}
1
+ {"version":3,"sources":["assets\\css\\atcb.css"],"names":[],"mappings":"AAYA,MACE,QAAS,KAGX,qBACE,QAAS,aACT,SAAU,SAGZ,aACE,WAAY,QACZ,OAAQ,IAAI,MAAM,QAClB,cAAe,IACf,mBAAoB,IAAI,IAAI,KAAK,EAAI,eACrC,WAAY,IAAI,IAAI,KAAK,EAAI,eAC7B,MAAO,KACP,OAAQ,QACR,QAAS,aACT,UAAW,KACX,YAAa,IACb,YAAa,KACb,OAAQ,KAAK,KACb,UAAW,MACX,UAAW,MACX,QAAS,KAAK,KAAK,KAAK,KACxB,SAAU,SACV,WAAY,OACZ,aAAc,aACd,oBAAqB,KACrB,iBAAkB,KAClB,gBAAiB,KACjB,YAAa,KACb,4BAA6B,YAC7B,MAAO,KAET,mBACE,WAAY,KAEd,yCACE,aACE,UAAW,MAIf,oBACE,WAAY,KACZ,cAAe,IAAI,IAAI,IAAI,IAC3B,mBAAoB,IAAI,IAAI,KAAK,EAAI,eACrC,WAAY,IAAI,IAAI,KAAK,EAAI,eAC7B,OAAQ,IAAI,KAAK,IAAI,KACrB,QAAS,KAAK,KAAK,KAAK,KACxB,QAAS,GAGX,WACE,OAAQ,KACR,QAAS,YACT,cAAe,IACf,aAAc,KACd,eAAgB,OAElB,eACE,OAAQ,KACR,MAAO,KACP,MAAO,KAGT,WACE,WAAY,WACZ,MAAO,KACP,QAAS,MACT,OAAQ,MAAM,KAAK,EAAE,KACrB,UAAW,KACX,SAAU,SACV,QAAS,EAAE,IACX,oBAAqB,KACrB,iBAAkB,KAClB,gBAAiB,KACjB,YAAa,KACb,MAAO,KACP,QAAS,GAGX,gBACE,WAAY,QACZ,OAAQ,IAAI,MAAM,QAClB,WAAY,EACZ,mBAAoB,IAAI,IAAI,IAAI,EAAI,eACpC,WAAY,IAAI,IAAI,IAAI,EAAI,eAC5B,WAAY,WACZ,OAAQ,QACR,UAAW,KACX,KAAM,IACN,SAAU,SACV,QAAS,KAAK,KACd,WAAY,KACZ,UAAW,gBACX,aAAc,aACd,4BAA6B,YAE/B,sBACE,WAAY,KACZ,mBAAoB,IAAI,IAAI,KAAK,EAAI,eACrC,WAAY,IAAI,IAAI,KAAK,EAAI,eAC7B,MAAO,KAET,yCACE,gBACE,UAAW,MAIf,4BACE,YAAa,KAGf,2BACE,cAAe,EAAE,EAAE,IAAI,IAIzB,2BACE,aAAc,IAGhB,gBACE,WAAY,kBACZ,gBAAiB,UACjB,OAAQ,KACR,KAAM,EACN,SAAU,MACV,IAAK,EACL,MAAO,KACP,QAAS"}
@@ -3,7 +3,7 @@
3
3
  * Add-to-Calendar Button
4
4
  * ++++++++++++++++++++++
5
5
  */
6
- const atcbVersion = '1.4.3';
6
+ const atcbVersion = '1.6.0';
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
@@ -46,7 +46,7 @@ function atcb_init() {
46
46
  atcbConfig['deleteJSON'] = true;
47
47
  }
48
48
  // rewrite config for backwards compatibility - you can remove this, if you did not use this script before v1.4.0.
49
- atcbConfig = atcb_rewrite_config(atcbConfig);
49
+ atcbConfig = atcb_patch_config(atcbConfig);
50
50
  // check, if all required data is available
51
51
  if (atcb_check_required(atcbConfig)) {
52
52
  // calculate the real date values in case that there are some special rules included (e.g. adding days dynamically)
@@ -91,7 +91,7 @@ function atcb_clean_schema_json(atcbConfig) {
91
91
 
92
92
 
93
93
  // BACKWARDS COMPATIBILITY REWRITE - you can remove this, if you did not use this script before v1.4.0.
94
- function atcb_rewrite_config(atcbConfig) {
94
+ function atcb_patch_config(atcbConfig) {
95
95
  const keyChanges = {
96
96
  'title': 'name',
97
97
  'dateStart': 'startDate',
@@ -138,11 +138,15 @@ function atcb_date_calculation(dateString) {
138
138
  // check for any dynamic additions and adjust
139
139
  const dateStringParts = dateString.split('+');
140
140
  const dateParts = dateStringParts[0].split('-');
141
- let newDate = new Date(dateParts[2], dateParts[0] - 1, dateParts[1]);
141
+ let newDate = new Date(dateParts[0], dateParts[1] - 1, dateParts[2]);
142
+ if (dateParts[0].length < 4) {
143
+ // backwards compatibility for version <1.5.0
144
+ newDate = new Date(dateParts[2], dateParts[0] - 1, dateParts[1]);
145
+ }
142
146
  if (dateStringParts[1] != null && dateStringParts[1] > 0) {
143
147
  newDate.setDate(newDate.getDate() + parseInt(dateStringParts[1]));
144
148
  }
145
- return (((newDate.getMonth() + 1) < 10 ? '0' : '') + (newDate.getMonth() + 1)) + '-' + (newDate.getDate() < 10 ? '0' : '') + newDate.getDate() + '-' + newDate.getFullYear();
149
+ return newDate.getFullYear() + '-' + (((newDate.getMonth() + 1) < 10 ? '0' : '') + (newDate.getMonth() + 1)) + '-' + (newDate.getDate() < 10 ? '0' : '') + newDate.getDate();
146
150
  }
147
151
 
148
152
 
@@ -150,7 +154,7 @@ function atcb_date_calculation(dateString) {
150
154
  // VALIDATE THE JSON DATA
151
155
  function atcb_validate(data) {
152
156
  // validate options
153
- const options = ['Apple', 'Google', 'iCal', 'Microsoft365', 'Outlook.com', 'Yahoo']
157
+ const options = ['Apple', 'Google', 'iCal', 'Microsoft365', 'Outlook.com', 'MicrosoftTeams', 'Yahoo']
154
158
  if (!data['options'].every(function(option) {
155
159
  let cleanOption = option.split('|');
156
160
  if (!options.includes(cleanOption[0])) {
@@ -170,7 +174,7 @@ function atcb_validate(data) {
170
174
  console.log("add-to-calendar button generation failed: date misspelled [" + date + ": " + data[date] + "]");
171
175
  return false;
172
176
  }
173
- newDate[date] = new Date(dateParts[2], dateParts[0] - 1, dateParts[1]);
177
+ newDate[date] = new Date(dateParts[0], dateParts[1] - 1, dateParts[2]);
174
178
  return true;
175
179
  })) {
176
180
  return false;
@@ -231,7 +235,7 @@ function atcb_generate(button, buttonId, data) {
231
235
  buttonTriggerWrapper.classList.add('atcb_button_wrapper');
232
236
  button.appendChild(buttonTriggerWrapper);
233
237
  // generate the button trigger div
234
- let buttonTrigger = document.createElement('div');
238
+ let buttonTrigger = document.createElement('button');
235
239
  buttonTrigger.id = 'atcb_button_' + buttonId;
236
240
  buttonTrigger.classList.add('atcb_button');
237
241
  buttonTrigger.dataset.atcbtn = buttonId;
@@ -240,13 +244,21 @@ function atcb_generate(button, buttonId, data) {
240
244
  buttonTrigger.innerHTML += '<span class="atcb_text">' + (data['label'] || 'Add to Calendar') + '</span>';
241
245
  // set event listeners for the button trigger
242
246
  if (data['trigger'] == 'click') {
243
- buttonTrigger.addEventListener('click', atcb_toggle, {passive: true});
247
+ buttonTrigger.addEventListener('mousedown', atcb_toggle);
244
248
  } else {
245
249
  buttonTrigger.addEventListener('touchstart', atcb_toggle, {passive: true});
246
- buttonTrigger.addEventListener('mouseenter', atcb_open, false);
250
+ buttonTrigger.addEventListener('mouseenter', atcb_open);
247
251
  }
248
- // standardize any line breaks in the description
252
+ buttonTrigger.addEventListener('focus', atcb_open);
253
+ buttonTrigger.addEventListener('keydown', function(event) { // trigger click on enter as well
254
+ if (event.key == 'Enter') {
255
+ atcb_toggle.call(event.target);
256
+ }
257
+ });
258
+ // standardize any line breaks in the description and transform URLs (but keep a clean copy without the URL magic for iCal)
249
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>");
250
262
  // generate the options list
251
263
  let optionsList = document.createElement('div');
252
264
  optionsList.id = 'atcb_list_' + buttonId;
@@ -257,7 +269,8 @@ function atcb_generate(button, buttonId, data) {
257
269
  data['options'].forEach(function(option) {
258
270
  let optionParts = option.split('|');
259
271
  let optionItem = document.createElement('div');
260
- optionItem.classList.add('atcb_list_item');
272
+ optionItem.classList.add('atcb_list_item');
273
+ optionItem.tabIndex = 0;
261
274
  optionsList.appendChild(optionItem);
262
275
  switch (optionParts[0]) {
263
276
  case "Apple":
@@ -268,7 +281,7 @@ function atcb_generate(button, buttonId, data) {
268
281
  optionItem.addEventListener('click', function() {
269
282
  atcb_generate_ical(data);
270
283
  atcb_close_all();
271
- }, false);
284
+ });
272
285
  break;
273
286
  case "Google":
274
287
  optionItem.innerHTML = '<span class="atcb_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 122.88 122.88"><path d="M93.78 29.1H29.1v64.68h64.68V29.1z" fill="#fff"/><path d="M93.78 122.88l29.1-29.1h-29.1v29.1z" fill="#f72a25"/><path d="M122.88 29.1h-29.1v64.68h29.1V29.1z" fill="#fbbc04"/><path d="M93.78 93.78H29.1v29.1h64.68v-29.1z" fill="#34a853"/><path d="M0 93.78v19.4c0 5.36 4.34 9.7 9.7 9.7h19.4v-29.1H0h0z" fill="#188038"/><path d="M122.88 29.1V9.7c0-5.36-4.34-9.7-9.7-9.7h-19.4v29.1h29.1 0z" fill="#1967d2"/><path d="M93.78 0H9.7C4.34 0 0 4.34 0 9.7v84.08h29.1V29.1h64.67V0h.01z" fill="#4285f4"/><path d="M42.37 79.27c-2.42-1.63-4.09-4.02-5-7.17l5.61-2.31c.51 1.94 1.4 3.44 2.67 4.51 1.26 1.07 2.8 1.59 4.59 1.59 1.84 0 3.41-.56 4.73-1.67 1.32-1.12 1.98-2.54 1.98-4.26 0-1.76-.7-3.2-2.09-4.32s-3.14-1.67-5.22-1.67H46.4v-5.55h2.91c1.79 0 3.31-.48 4.54-1.46 1.23-.97 1.84-2.3 1.84-3.99 0-1.5-.55-2.7-1.65-3.6s-2.49-1.35-4.18-1.35c-1.65 0-2.96.44-3.93 1.32s-1.7 2-2.12 3.24l-5.55-2.31c.74-2.09 2.09-3.93 4.07-5.52s4.51-2.39 7.58-2.39c2.27 0 4.32.44 6.13 1.32s3.23 2.1 4.26 3.65c1.03 1.56 1.54 3.31 1.54 5.25 0 1.98-.48 3.65-1.43 5.03-.95 1.37-2.13 2.43-3.52 3.16v.33c1.79.74 3.36 1.96 4.51 3.52 1.17 1.58 1.76 3.46 1.76 5.66s-.56 4.16-1.67 5.88c-1.12 1.72-2.66 3.08-4.62 4.07s-4.17 1.49-6.62 1.49c-2.84 0-5.46-.81-7.88-2.45h0 0zm34.46-27.84l-6.16 4.45-3.08-4.67 11.05-7.97h4.24v37.6h-6.05V51.43h0z" fill="#1a73e8"/></svg></span>';
@@ -278,7 +291,7 @@ function atcb_generate(button, buttonId, data) {
278
291
  optionItem.addEventListener('click', function() {
279
292
  atcb_generate_google(data);
280
293
  atcb_close_all();
281
- }, false);
294
+ });
282
295
  break;
283
296
  case "iCal":
284
297
  optionItem.innerHTML = '<span class="atcb_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 122.88 122.88"><path d="M81.61 4.73c0-2.61 2.58-4.73 5.77-4.73s5.77 2.12 5.77 4.73v20.72c0 2.61-2.58 4.73-5.77 4.73s-5.77-2.12-5.77-4.73V4.73h0zm-15.5 99.08c-.34 0-.61-1.43-.61-3.2s.27-3.2.61-3.2H81.9c.34 0 .61 1.43.61 3.2s-.27 3.2-.61 3.2H66.11h0zM15.85 67.09c-.34 0-.61-1.43-.61-3.2s.27-3.2.61-3.2h15.79c.34 0 .61 1.43.61 3.2s-.27 3.2-.61 3.2H15.85h0zm25.13 0c-.34 0-.61-1.43-.61-3.2s.27-3.2.61-3.2h15.79c.34 0 .61 1.43.61 3.2s-.27 3.2-.61 3.2H40.98h0zm25.13 0c-.34 0-.61-1.43-.61-3.2s.27-3.2.61-3.2H81.9c.34 0 .61 1.43.61 3.2s-.27 3.2-.61 3.2H66.11h0zm25.14 0c-.34 0-.61-1.43-.61-3.2s.27-3.2.61-3.2h15.79c.34 0 .61 1.43.61 3.2s-.27 3.2-.61 3.2H91.25h0zm-75.4 18.36c-.34 0-.61-1.43-.61-3.2s.27-3.2.61-3.2h15.79c.34 0 .61 1.43.61 3.2s-.27 3.2-.61 3.2H15.85h0zm25.13 0c-.34 0-.61-1.43-.61-3.2s.27-3.2.61-3.2h15.79c.34 0 .61 1.43.61 3.2s-.27 3.2-.61 3.2H40.98h0zm25.13 0c-.34 0-.61-1.43-.61-3.2s.27-3.2.61-3.2H81.9c.34 0 .61 1.43.61 3.2s-.27 3.2-.61 3.2H66.11h0zm25.14 0c-.34 0-.61-1.43-.61-3.2s.27-3.2.61-3.2h15.79c.34 0 .61 1.43.61 3.2s-.27 3.2-.61 3.2H91.25h0zm-75.4 18.36c-.34 0-.61-1.43-.61-3.2s.27-3.2.61-3.2h15.79c.34 0 .61 1.43.61 3.2s-.27 3.2-.61 3.2H15.85h0zm25.13 0c-.34 0-.61-1.43-.61-3.2s.27-3.2.61-3.2h15.79c.34 0 .61 1.43.61 3.2s-.27 3.2-.61 3.2H40.98h0zM29.61 4.73c0-2.61 2.58-4.73 5.77-4.73s5.77 2.12 5.77 4.73v20.72c0 2.61-2.58 4.73-5.77 4.73s-5.77-2.12-5.77-4.73V4.73h0zM6.4 45.32h110.07V21.47c0-.8-.33-1.53-.86-2.07-.53-.53-1.26-.86-2.07-.86H103c-1.77 0-3.2-1.43-3.2-3.2s1.43-3.2 3.2-3.2h10.55c2.57 0 4.9 1.05 6.59 2.74s2.74 4.02 2.74 6.59v27.06 65.03c0 2.57-1.05 4.9-2.74 6.59s-4.02 2.74-6.59 2.74H9.33c-2.57 0-4.9-1.05-6.59-2.74-1.69-1.7-2.74-4.03-2.74-6.6V48.52 21.47c0-2.57 1.05-4.9 2.74-6.59s4.02-2.74 6.59-2.74H20.6c1.77 0 3.2 1.43 3.2 3.2s-1.43 3.2-3.2 3.2H9.33c-.8 0-1.53.33-2.07.86-.53.53-.86 1.26-.86 2.07v23.85h0zm110.08 6.41H6.4v61.82c0 .8.33 1.53.86 2.07.53.53 1.26.86 2.07.86h104.22c.8 0 1.53-.33 2.07-.86.53-.53.86-1.26.86-2.07V51.73h0zM50.43 18.54c-1.77 0-3.2-1.43-3.2-3.2s1.43-3.2 3.2-3.2h21.49c1.77 0 3.2 1.43 3.2 3.2s-1.43 3.2-3.2 3.2H50.43h0z"/></svg></span>';
@@ -288,7 +301,17 @@ function atcb_generate(button, buttonId, data) {
288
301
  optionItem.addEventListener('click', function() {
289
302
  atcb_generate_ical(data);
290
303
  atcb_close_all();
291
- }, false);
304
+ });
305
+ break;
306
+ case "MicrosoftTeams":
307
+ optionItem.innerHTML = '<span class="atcb_icon"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 2228.833 2073.333"><g fill="#5059c9"><path d="M1554.637 777.5h575.713c54.391 0 98.483 44.092 98.483 98.483v524.398c0 199.901-162.051 361.952-361.952 361.952h0-1.711c-199.901.028-361.975-162-362.004-361.901v-.052-571.409c.001-28.427 23.045-51.471 51.471-51.471h0z"/><circle cx="1943.75" cy="440.583" r="233.25"/></g><g fill="#7b83eb"><circle cx="1218.083" cy="336.917" r="336.917"/><path d="M1667.323 777.5H717.01c-53.743 1.33-96.257 45.931-95.01 99.676v598.105c-7.505 322.519 247.657 590.16 570.167 598.053 322.51-7.893 577.671-275.534 570.167-598.053V877.176c1.245-53.745-41.268-98.346-95.011-99.676z"/></g><path opacity=".1" d="M1244 777.5v838.145c-.258 38.435-23.549 72.964-59.09 87.598-11.316 4.787-23.478 7.254-35.765 7.257H667.613c-6.738-17.105-12.958-34.21-18.142-51.833-18.144-59.477-27.402-121.307-27.472-183.49V877.02c-1.246-53.659 41.198-98.19 94.855-99.52H1244z"/><path opacity=".2" d="M1192.167 777.5v889.978a91.84 91.84 0 0 1-7.257 35.765c-14.634 35.541-49.163 58.833-87.598 59.09H691.975c-8.812-17.105-17.105-34.21-24.362-51.833s-12.958-34.21-18.142-51.833a631.28 631.28 0 0 1-27.472-183.49V877.02c-1.246-53.659 41.198-98.19 94.855-99.52h475.313z"/><path opacity=".2" d="M1192.167 777.5v786.312c-.395 52.223-42.632 94.46-94.855 94.855h-447.84A631.28 631.28 0 0 1 622 1475.177V877.02c-1.246-53.659 41.198-98.19 94.855-99.52h475.312z"/><path opacity=".2" d="M1140.333 777.5v786.312c-.395 52.223-42.632 94.46-94.855 94.855H649.472A631.28 631.28 0 0 1 622 1475.177V877.02c-1.246-53.659 41.198-98.19 94.855-99.52h423.478z"/><path opacity=".1" d="M1244 509.522v163.275c-8.812.518-17.105 1.037-25.917 1.037s-17.105-.518-25.917-1.037c-17.496-1.161-34.848-3.937-51.833-8.293a336.92 336.92 0 0 1-233.25-198.003 288.02 288.02 0 0 1-16.587-51.833h258.648c52.305.198 94.657 42.549 94.856 94.854z"/><use xlink:href="#C" opacity=".2"/><use xlink:href="#C" opacity=".2"/><path opacity=".2" d="M1140.333 561.355v103.148A336.92 336.92 0 0 1 907.083 466.5h138.395c52.305.199 94.656 42.551 94.855 94.855z"/><linearGradient id="A" gradientUnits="userSpaceOnUse" x1="198.099" y1="392.261" x2="942.234" y2="1681.073"><stop offset="0" stop-color="#5a62c3"/><stop offset=".5" stop-color="#4d55bd"/><stop offset="1" stop-color="#3940ab"/></linearGradient><path fill="url(#A)" d="M95.01 466.5h950.312c52.473 0 95.01 42.538 95.01 95.01v950.312c0 52.473-42.538 95.01-95.01 95.01H95.01c-52.473 0-95.01-42.538-95.01-95.01V561.51c0-52.472 42.538-95.01 95.01-95.01z"/><path fill="#fff" d="M820.211,828.193H630.241v517.297H509.211V828.193H320.123V727.844h500.088V828.193z"/><defs ><path id="C" d="M1192.167 561.355v111.442c-17.496-1.161-34.848-3.937-51.833-8.293a336.92 336.92 0 0 1-233.25-198.003h190.228c52.304.198 94.656 42.55 94.855 94.854z"/></defs></svg></span>';
308
+ optionItem.innerHTML += '<span class="atcb_text">';
309
+ optionItem.innerHTML += optionParts[1] || 'Microsoft Teams';
310
+ optionItem.innerHTML += '</span>';
311
+ optionItem.addEventListener('click', function() {
312
+ atcb_generate_teams(data);
313
+ atcb_close_all();
314
+ });
292
315
  break;
293
316
  case "Microsoft365":
294
317
  optionItem.innerHTML = '<span class="atcb_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 278050 333334" shape-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd"><path fill="#ea3e23" d="M278050 305556l-29-16V28627L178807 0 448 66971l-448 87 22 200227 60865-23821V80555l117920-28193-17 239519L122 267285l178668 65976v73l99231-27462v-316z"/></svg></span>';
@@ -298,7 +321,7 @@ function atcb_generate(button, buttonId, data) {
298
321
  optionItem.addEventListener('click', function() {
299
322
  atcb_generate_microsoft(data, '365');
300
323
  atcb_close_all();
301
- }, false);
324
+ });
302
325
  break;
303
326
  case "Outlook.com":
304
327
  optionItem.innerHTML = '<span class="atcb_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.129793726981 0 33.251996719421 32" width="2500" height="2397"><path d="M28.596 2H11.404A1.404 1.404 0 0 0 10 3.404V5l9.69 3L30 5V3.404A1.404 1.404 0 0 0 28.596 2z" fill="#0364b8"/><path d="M31.65 17.405A11.341 11.341 0 0 0 32 16a.666.666 0 0 0-.333-.576l-.013-.008-.004-.002L20.812 9.24a1.499 1.499 0 0 0-1.479-.083 1.49 1.49 0 0 0-.145.082L8.35 15.415l-.004.002-.012.007A.666.666 0 0 0 8 16a11.344 11.344 0 0 0 .35 1.405l11.492 8.405z" fill="#0a2767"/><path d="M24 5h-7l-2.021 3L17 11l7 6h6v-6z" fill="#28a8ea"/><path d="M10 5h7v6h-7z" fill="#0078d4"/><path d="M24 5h6v6h-6z" fill="#50d9ff"/><path d="M24 17l-7-6h-7v6l7 6 10.832 1.768z" fill="#0364b8"/><path d="M17 11h7v6h-7z" fill="#0078d4"/><path d="M10 17h7v6h-7z" fill="#064a8c"/><path d="M24 17h6v6h-6z" fill="#0078d4"/><path d="M20.19 25.218l-11.793-8.6.495-.87 10.909 6.212a.528.528 0 0 0 .42-.012l10.933-6.23.496.869z" fill="#0a2767" opacity=".5"/><path d="M31.667 16.577l-.014.008-.003.002-10.838 6.174a1.497 1.497 0 0 1-1.46.091l3.774 5.061 8.254 1.797v.004A1.498 1.498 0 0 0 32 28.5V16a.666.666 0 0 1-.333.577z" fill="#1490df"/><path d="M32 28.5v-.738l-9.983-5.688-1.205.687a1.497 1.497 0 0 1-1.46.091l3.774 5.061 8.254 1.797v.004A1.498 1.498 0 0 0 32 28.5z" opacity=".05"/><path d="M31.95 28.883L21.007 22.65l-.195.11a1.497 1.497 0 0 1-1.46.092l3.774 5.061 8.254 1.797v.004a1.501 1.501 0 0 0 .57-.83z" opacity=".1"/><path d="M8.35 16.59v-.01h-.01l-.03-.02A.65.65 0 0 1 8 16v12.5A1.498 1.498 0 0 0 9.5 30h21a1.503 1.503 0 0 0 .37-.05.637.637 0 0 0 .18-.06.142.142 0 0 0 .06-.02 1.048 1.048 0 0 0 .23-.13c.02-.01.03-.01.04-.03z" fill="#28a8ea"/><path d="M18 24.667V8.333A1.337 1.337 0 0 0 16.667 7H10.03v7.456l-1.68.958-.005.002-.012.007A.666.666 0 0 0 8 16v.005V16v10h8.667A1.337 1.337 0 0 0 18 24.667z" opacity=".1"/><path d="M17 25.667V9.333A1.337 1.337 0 0 0 15.667 8H10.03v6.456l-1.68.958-.005.002-.012.007A.666.666 0 0 0 8 16v.005V16v11h7.667A1.337 1.337 0 0 0 17 25.667z" opacity=".2"/><path d="M17 23.667V9.333A1.337 1.337 0 0 0 15.667 8H10.03v6.456l-1.68.958-.005.002-.012.007A.666.666 0 0 0 8 16v.005V16v9h7.667A1.337 1.337 0 0 0 17 23.667z" opacity=".2"/><path d="M16 23.667V9.333A1.337 1.337 0 0 0 14.667 8H10.03v6.456l-1.68.958-.005.002-.012.007A.666.666 0 0 0 8 16v.005V16v9h6.667A1.337 1.337 0 0 0 16 23.667z" opacity=".2"/><path d="M1.333 8h13.334A1.333 1.333 0 0 1 16 9.333v13.334A1.333 1.333 0 0 1 14.667 24H1.333A1.333 1.333 0 0 1 0 22.667V9.333A1.333 1.333 0 0 1 1.333 8z" fill="#0078d4"/><path d="M3.867 13.468a4.181 4.181 0 0 1 1.642-1.814A4.965 4.965 0 0 1 8.119 11a4.617 4.617 0 0 1 2.413.62 4.14 4.14 0 0 1 1.598 1.733 5.597 5.597 0 0 1 .56 2.55 5.901 5.901 0 0 1-.577 2.666 4.239 4.239 0 0 1-1.645 1.794A4.8 4.8 0 0 1 7.963 21a4.729 4.729 0 0 1-2.468-.627 4.204 4.204 0 0 1-1.618-1.736 5.459 5.459 0 0 1-.567-2.519 6.055 6.055 0 0 1 .557-2.65zm1.75 4.258a2.716 2.716 0 0 0 .923 1.194 2.411 2.411 0 0 0 1.443.435 2.533 2.533 0 0 0 1.541-.449 2.603 2.603 0 0 0 .897-1.197 4.626 4.626 0 0 0 .286-1.665 5.063 5.063 0 0 0-.27-1.686 2.669 2.669 0 0 0-.866-1.24 2.387 2.387 0 0 0-1.527-.473 2.493 2.493 0 0 0-1.477.439 2.741 2.741 0 0 0-.944 1.203 4.776 4.776 0 0 0-.007 3.44z" fill="#fff"/></svg></span>';
@@ -308,7 +331,7 @@ function atcb_generate(button, buttonId, data) {
308
331
  optionItem.addEventListener('click', function() {
309
332
  atcb_generate_microsoft(data, 'outlook');
310
333
  atcb_close_all();
311
- }, false);
334
+ });
312
335
  break;
313
336
  case "Yahoo":
314
337
  optionItem.innerHTML = '<span class="atcb_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3386.34 3010.5" shape-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd"><path d="M0 732.88h645.84l376.07 962.1 380.96-962.1h628.76l-946.8 2277.62H451.98l259.19-603.53L.02 732.88zm2763.84 768.75h-704.26L2684.65 0l701.69.03-622.5 1501.6zm-519.78 143.72c216.09 0 391.25 175.17 391.25 391.22 0 216.06-175.16 391.23-391.25 391.23-216.06 0-391.19-175.17-391.19-391.23 0-216.05 175.16-391.22 391.19-391.22z" fill="#5f01d1" fill-rule="nonzero"/></svg></span>';
@@ -318,19 +341,26 @@ function atcb_generate(button, buttonId, data) {
318
341
  optionItem.addEventListener('click', function() {
319
342
  atcb_generate_yahoo(data);
320
343
  atcb_close_all();
321
- }, false);
344
+ });
322
345
  break;
323
346
  }
347
+ optionItem.addEventListener('keydown', function(event) { // trigger click on enter as well
348
+ if (event.key == 'Enter') {
349
+ this.click();
350
+ }
351
+ });
324
352
  });
325
353
  // create the background overlay, which also acts as trigger to close any dropdowns
326
354
  let bgOverlay = document.createElement('div');
327
355
  bgOverlay.id = 'atcb_bgoverlay_' + buttonId;
328
356
  bgOverlay.classList.add('atcb_bgoverlay');
329
357
  bgOverlay.style.display = 'none';
358
+ bgOverlay.tabIndex = 0;
330
359
  button.appendChild(bgOverlay);
331
- bgOverlay.addEventListener('click', atcb_close_all, {passive: true});
360
+ bgOverlay.addEventListener('click', atcb_close_all);
332
361
  bgOverlay.addEventListener('touchstart', atcb_close_all, {passive: true});
333
- bgOverlay.addEventListener('mouseenter', atcb_close_all, false);
362
+ bgOverlay.addEventListener('mousemove', atcb_close_all);
363
+ bgOverlay.addEventListener('focus', atcb_close_all);
334
364
  // update the placeholder class to prevent multiple initializations
335
365
  button.classList.remove('atcb');
336
366
  button.classList.add('atcb_initialized');
@@ -372,7 +402,6 @@ function atcb_close() {
372
402
  document.getElementById('atcb_bgoverlay_' + this.dataset.atcbtn).style.display = 'none';
373
403
  }
374
404
 
375
-
376
405
  function atcb_close_all() {
377
406
  // get all buttons
378
407
  let atcButtons = document.querySelectorAll('.atcb_button');
@@ -442,14 +471,14 @@ function atcb_generate_microsoft(data, type = '365') {
442
471
  }
443
472
  url += '/calendar/0/deeplink/compose?path=%2Fcalendar%2Faction%2Fcompose&rru=addevent';
444
473
  // generate and add date
445
- let formattedDate = atcb_generate_time(data, 'delimiters', 'microsoft');
474
+ let formattedDate = atcb_generate_time(data, 'delimiters', 'microsoft');
446
475
  url += '&startdt=' + formattedDate['start'] + '&enddt=' + formattedDate['end'];
447
476
  if (formattedDate['allday']) {
448
477
  url += '&allday=true';
449
478
  }
450
479
  // add details (if set)
451
480
  if (data['description'] != null && data['description'] != '') {
452
- url += '&body=' + encodeURIComponent(data['description']);
481
+ url += '&body=' + encodeURIComponent(data['description'].replace(/\n/g, '<br>'));
453
482
  }
454
483
  if (data['location'] != null && data['location'] != '') {
455
484
  url += '&location=' + encodeURIComponent(data['location']);
@@ -462,15 +491,42 @@ function atcb_generate_microsoft(data, type = '365') {
462
491
 
463
492
 
464
493
 
494
+ // FUNCTION TO GENERATE THE MICROSOFT TEAMS URL
495
+ // Mind that this is still in development mode by Microsoft! (https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/build-and-test/deep-links#deep-linking-to-the-scheduling-dialog)
496
+ // Location, html tags and linebreaks in the description are not supported yet.
497
+ function atcb_generate_teams(data) {
498
+ // base url
499
+ let url = 'https://teams.microsoft.com/l/meeting/new?';
500
+ // generate and add date
501
+ let formattedDate = atcb_generate_time(data, 'delimiters', 'microsoft');
502
+ url += '&startTime=' + formattedDate['start'] + '&endTime=' + formattedDate['end'];
503
+ // add details (if set)
504
+ let locationString = '';
505
+ if (data['location'] != null && data['location'] != '') {
506
+ locationString = encodeURIComponent(data['location']);
507
+ url += '&location=' + locationString; // workaround putting the location into the description, since the native field is not supported yet
508
+ locationString += ' // ';
509
+ }
510
+ if (data['description_iCal'] != null && data['description_iCal'] != '') { // using description_iCal instead of description, since Teams does not support html tags
511
+ url += '&content=' + locationString + encodeURIComponent(data['description_iCal']);
512
+ }
513
+ if (data['name'] != null && data['name'] != '') {
514
+ url += '&subject=' + encodeURIComponent(data['name']);
515
+ }
516
+ window.open(url, '_blank').focus();
517
+ }
518
+
519
+
520
+
465
521
  // FUNCTION TO GENERATE THE iCAL FILE (also for the Apple option)
466
- function atcb_generate_ical(data) {
522
+ function atcb_generate_ical(data) {
467
523
  let now = new Date();
468
524
  now = now.toISOString().replace(/\-/g, '').replace(/\:/g, '').replace(/\..../g, '');
469
525
  let formattedDate = atcb_generate_time(data, 'clean', 'ical');
470
526
  let timeslot = '';
471
527
  if (formattedDate['allday']) {
472
528
  timeslot = ';VALUE=DATE';
473
- }
529
+ }
474
530
  let ics_lines = [
475
531
  "BEGIN:VCALENDAR",
476
532
  "VERSION:2.0",
@@ -479,7 +535,7 @@ function atcb_generate_ical(data) {
479
535
  "DTSTAMP:" + formattedDate['start'],
480
536
  "DTSTART" + timeslot + ":" + formattedDate['start'],
481
537
  "DTEND" + timeslot + ":" + formattedDate['end'],
482
- "DESCRIPTION:" + data['description'].replace(/\n/g, '\\n'),
538
+ "DESCRIPTION:" + data['description_iCal'].replace(/\n/g, '\\n'),
483
539
  "SUMMARY:" + data['name'],
484
540
  "LOCATION:" + data['location'],
485
541
  "STATUS:CONFIRMED",
@@ -488,7 +544,7 @@ function atcb_generate_ical(data) {
488
544
  "END:VEVENT",
489
545
  "END:VCALENDAR"
490
546
  ];
491
- let dlurl = 'data:text/calendar;base64,'+btoa(ics_lines.join('\r\n').replace(/[\u00A0-\u2666]/g, function(c) { return '&#' + c.charCodeAt(0) + ';'; })); // includes a fix to not throw an error with non-Latin1 characters. However, still needs improvement, since it shows up encoded in the iCal file.
547
+ let dlurl = 'data:text/calendar;charset=utf-8,'+encodeURIComponent(ics_lines.join('\r\n'));
492
548
  try {
493
549
  if (!window.ActiveXObject) {
494
550
  let save = document.createElement('a');
@@ -500,7 +556,7 @@ function atcb_generate_ical(data) {
500
556
  'bubbles': true,
501
557
  'cancelable': false
502
558
  });
503
- save.dispatchEvent(evt);
559
+ save.dispatchEvent(evt);
504
560
  (window.URL || window.webkitURL).revokeObjectURL(save.href);
505
561
  }
506
562
  } catch(e) {
@@ -521,8 +577,8 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general') {
521
577
  // Adjust for timezone, if set (see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for either the TZ name or the offset)
522
578
  if (data['timeZoneOffset'] != null && data['timeZoneOffset'] != '') {
523
579
  // if we have a timezone offset given, consider it
524
- start = new Date( startDate[2] + '-' + startDate[0] + '-' + startDate[1] + 'T' + data['startTime'] + ':00.000' + data['timeZoneOffset'] );
525
- end = new Date( endDate[2] + '-' + endDate[0] + '-' + endDate[1] + 'T' + data['endTime'] + ':00.000' + data['timeZoneOffset'] );
580
+ start = new Date( startDate[0] + '-' + startDate[1] + '-' + startDate[2] + 'T' + data['startTime'] + ':00.000' + data['timeZoneOffset'] );
581
+ end = new Date( endDate[0] + '-' + endDate[1] + '-' + endDate[2] + 'T' + data['endTime'] + ':00.000' + data['timeZoneOffset'] );
526
582
  start = start.toISOString().replace('.000', '');
527
583
  end = end.toISOString().replace('.000', '');
528
584
  if (style == 'clean') {
@@ -531,8 +587,8 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general') {
531
587
  }
532
588
  } else {
533
589
  // if there is no offset, we prepare the time, assuming it is UTC formatted
534
- start = new Date( startDate[2] + '-' + startDate[0] + '-' + startDate[1] + 'T' + data['startTime'] + ':00.000+00:00' );
535
- end = new Date( endDate[2] + '-' + endDate[0] + '-' + endDate[1] + 'T' + data['endTime'] + ':00.000+00:00' );
590
+ start = new Date( startDate[0] + '-' + startDate[1] + '-' + startDate[2] + 'T' + data['startTime'] + ':00.000+00:00' );
591
+ end = new Date( endDate[0] + '-' + endDate[1] + '-' + endDate[2] + 'T' + data['endTime'] + ':00.000+00:00' );
536
592
  if (data['timeZone'] != null && data['timeZone'] != '') {
537
593
  // if a timezone is given, we adjust dynamically with the modern toLocaleString function
538
594
  let utcDate = new Date(start.toLocaleString('en-US', { timeZone: "UTC" }));
@@ -553,10 +609,10 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general') {
553
609
  }
554
610
  } else { // would be an allday event then
555
611
  allday = true;
556
- start = new Date( startDate[2], startDate[0] - 1, startDate[1]);
612
+ start = new Date( startDate[0], startDate[1] - 1, startDate[2]);
557
613
  start.setDate(start.getDate() + 1); // increment the day by 1
558
614
  let breakStart = start.toISOString().split('T');
559
- end = new Date( endDate[2], endDate[0] - 1, endDate[1]);
615
+ end = new Date( endDate[0], endDate[1] - 1, endDate[2]);
560
616
  if (targetCal == 'google' || targetCal == 'microsoft' || targetCal == 'ical') {
561
617
  end.setDate(end.getDate() + 2); // increment the day by 2 for Google Calendar, iCal and Outlook
562
618
  } else {
@@ -576,4 +632,4 @@ function atcb_generate_time(data, style = 'delimiters', targetCal = 'general') {
576
632
 
577
633
 
578
634
 
579
- export { atcb_init };
635
+ export { atcb_init };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "add-to-calendar-button",
3
- "version": "1.4.3",
3
+ "version": "1.6.0",
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/atcb_npm.js",
6
6
  "types": "index.d.ts",