Skip to content

Commit cbbd86e

Browse files
committed
fix ical function issue
1 parent e51ef56 commit cbbd86e

File tree

5 files changed

+27
-32
lines changed

5 files changed

+27
-32
lines changed

assets/css/atcb.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*
6-
* Version: 1.1.2
6+
* Version: 1.1.3
77
* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: GNU General Public License v3.0 (gpl-3.0)

assets/js/atcb.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Add-to-Calendar Button
44
* ++++++++++++++++++++++
55
*/
6-
const atcbVersion = '1.1.2';
6+
const atcbVersion = '1.1.3';
77
/* Creator: Jens Kuerschner (https://jenskuerschner.de)
88
* Project: https://github.com/jekuer/add-to-calendar-button
99
* License: GNU General Public License v3.0 (gpl-3.0)
@@ -382,22 +382,7 @@ function atcb_generate_microsoft(data, type = '365') {
382382

383383

384384
// FUNCTION TO GENERATE THE iCAL FILE (also for the Apple option)
385-
function atcb_generate_ical(data) {
386-
this._save = function(fileURL) {
387-
if (!window.ActiveXObject) {
388-
let save = document.createElement('a');
389-
save.href = fileURL;
390-
save.target = '_blank';
391-
save.download = data['iCalFileName'] || 'event-to-save-in-my-calendar';
392-
let evt = new MouseEvent('click', {
393-
'view': window,
394-
'bubbles': true,
395-
'cancelable': false
396-
});
397-
save.dispatchEvent(evt);
398-
(window.URL || window.webkitURL).revokeObjectURL(save.href);
399-
}
400-
}
385+
function atcb_generate_ical(data) {
401386
let now = new Date();
402387
now = now.toISOString().replace(/\-/g, '').replace(/\:/g, '').replace(/\..../g, '');
403388
let formattedDate = atcb_generate_time(data, 'clean', 'ical');
@@ -424,7 +409,19 @@ function atcb_generate_ical(data) {
424409
];
425410
let dlurl = 'data:text/calendar;base64,'+btoa(ics_lines.join('\r\n'));
426411
try {
427-
this._save(dlurl);
412+
if (!window.ActiveXObject) {
413+
let save = document.createElement('a');
414+
save.href = dlurl;
415+
save.target = '_blank';
416+
save.download = data['iCalFileName'] || 'event-to-save-in-my-calendar';
417+
let evt = new MouseEvent('click', {
418+
'view': window,
419+
'bubbles': true,
420+
'cancelable': false
421+
});
422+
save.dispatchEvent(evt);
423+
(window.URL || window.webkitURL).revokeObjectURL(save.href);
424+
}
428425
} catch(e) {
429426
console.log(e);
430427
}
@@ -501,4 +498,4 @@ document.addEventListener('DOMContentLoaded', atcb_init, false);
501498

502499

503500
// EXPORT FOR USE IN NODEJS
504-
export { atcb_init };
501+
export { atcb_init, atcbVersion };

0 commit comments

Comments
 (0)