add-to-calendar-button 2.6.21 → 2.7.1
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/CHANGELOG.md +1 -0
- package/assets/css/atcb-3d.css +13 -2
- package/assets/css/atcb-3d.min.css +1 -1
- package/assets/css/atcb-date.css +13 -2
- package/assets/css/atcb-date.min.css +1 -1
- package/assets/css/atcb-flat.css +14 -3
- package/assets/css/atcb-flat.min.css +1 -1
- package/assets/css/atcb-neumorphism.css +13 -2
- package/assets/css/atcb-neumorphism.min.css +1 -1
- package/assets/css/atcb-round.css +13 -2
- package/assets/css/atcb-round.min.css +1 -1
- package/assets/css/atcb-text.css +13 -2
- package/assets/css/atcb-text.min.css +1 -1
- package/assets/css/atcb.css +13 -2
- package/assets/css/atcb.min.css +1 -1
- package/dist/atcb-no-pro-unstyle.js +100 -80
- package/dist/atcb-no-pro.js +101 -81
- package/dist/atcb-unstyle.js +115 -96
- package/dist/atcb.js +116 -97
- package/dist/commonjs/index.js +116 -97
- package/dist/commonjs/no-pro/index.js +101 -81
- package/dist/commonjs/no-pro-unstyle/index.js +100 -80
- package/dist/commonjs/unstyle/index.js +115 -96
- package/dist/module/index.js +116 -97
- package/dist/module/no-pro/index.js +101 -81
- package/dist/module/no-pro-unstyle/index.js +100 -80
- package/dist/module/unstyle/index.js +115 -96
- package/package.json +1 -1
|
@@ -6,15 +6,15 @@ const tzlibActions = require('timezones-ical-library');
|
|
|
6
6
|
* Add to Calendar Button
|
|
7
7
|
* ++++++++++++++++++++++
|
|
8
8
|
*
|
|
9
|
-
* Version: 2.
|
|
9
|
+
* Version: 2.7.1
|
|
10
10
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
11
11
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
12
12
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
13
13
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
const atcbVersion = '2.
|
|
17
|
-
const atcbCssTemplate = {
|
|
16
|
+
const atcbVersion = '2.7.1';
|
|
17
|
+
const atcbCssTemplate = {
|
|
18
18
|
if (typeof window === 'undefined') {
|
|
19
19
|
return false;
|
|
20
20
|
} else {
|
|
@@ -547,8 +547,9 @@ function atcb_decorate_data_description(data, i) {
|
|
|
547
547
|
description = cleanDescription(description);
|
|
548
548
|
if (data.customVar) {
|
|
549
549
|
for (const key in data.customVar) {
|
|
550
|
-
const sanitizedKey = key.replace(/[^\w\-.]/g, '');
|
|
551
|
-
|
|
550
|
+
const sanitizedKey = '%%' + key.replace(/[^\w\-.]/g, '') + '%%';
|
|
551
|
+
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
552
|
+
description = description.replace(new RegExp(sanitizedKey, 'gi'), data.customVar[`${key}`]);
|
|
552
553
|
}
|
|
553
554
|
}
|
|
554
555
|
const descriptionHtmlFree = atcb_rewrite_html_elements(description, true);
|
|
@@ -606,9 +607,11 @@ function atcb_decorate_data_extend(data) {
|
|
|
606
607
|
}
|
|
607
608
|
if (data.customVar) {
|
|
608
609
|
for (const key in data.customVar) {
|
|
609
|
-
const sanitizedKey = key.replace(/[^\w\-.]/g, '');
|
|
610
|
-
|
|
611
|
-
data.dates[`${i}`].
|
|
610
|
+
const sanitizedKey = '%%' + key.replace(/[^\w\-.]/g, '') + '%%';
|
|
611
|
+
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
612
|
+
data.dates[`${i}`].name = data.dates[`${i}`].name.replace(new RegExp(sanitizedKey, 'gi'), data.customVar[`${key}`]);
|
|
613
|
+
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
614
|
+
data.dates[`${i}`].location = data.dates[`${i}`].location.replace(new RegExp(sanitizedKey, 'gi'), data.customVar[`${key}`]);
|
|
612
615
|
}
|
|
613
616
|
}
|
|
614
617
|
}
|
|
@@ -621,26 +624,31 @@ function atcb_decorate_data_extend(data) {
|
|
|
621
624
|
return data;
|
|
622
625
|
}
|
|
623
626
|
function atcb_date_cleanup(dateTimeData) {
|
|
627
|
+
function isValidDateFormat(dateStr) {
|
|
628
|
+
return /^\d\d\d\d-\d\d-\d\d(?:T\d\d:\d\d)?(?::\d\d)?(?:.\d\d\d)?Z?$/i.test(dateStr);
|
|
629
|
+
}
|
|
630
|
+
function isValidTodayFormat(dateStr) {
|
|
631
|
+
return /^today(?:\+(?:\d|\d\d|\d\d\d|\d\d\d\d))?$/i.test(dateStr);
|
|
632
|
+
}
|
|
624
633
|
if (!dateTimeData.endDate || dateTimeData.endDate === '') {
|
|
625
634
|
dateTimeData.endDate = dateTimeData.startDate;
|
|
626
635
|
}
|
|
627
636
|
const endpoints = ['start', 'end'];
|
|
628
637
|
endpoints.forEach(function (point) {
|
|
629
|
-
|
|
638
|
+
const dateStr = dateTimeData[point + 'Date'];
|
|
639
|
+
if (!isValidDateFormat(dateStr) && !isValidTodayFormat(dateStr)) {
|
|
630
640
|
dateTimeData[point + 'Date'] = 'badly-formed';
|
|
631
641
|
} else {
|
|
632
|
-
dateTimeData[point + 'Date'] = atcb_date_calculation(
|
|
642
|
+
if (isValidTodayFormat(dateStr)) dateTimeData[point + 'Date'] = atcb_date_calculation(dateStr);
|
|
633
643
|
if (dateTimeData[point + 'Date']) {
|
|
634
|
-
dateTimeData[point + 'Date'] = dateTimeData[point + 'Date'].replace(/\.\d{3}/, '').replace('Z', '');
|
|
635
644
|
const tmpSplitStartDate = dateTimeData[point + 'Date'].split('T');
|
|
636
645
|
if (tmpSplitStartDate[1]) {
|
|
637
646
|
dateTimeData[point + 'Date'] = tmpSplitStartDate[0];
|
|
638
647
|
dateTimeData[point + 'Time'] = tmpSplitStartDate[1];
|
|
639
648
|
}
|
|
640
649
|
}
|
|
641
|
-
if (dateTimeData[point + 'Time'] && dateTimeData[point + 'Time'].length
|
|
642
|
-
|
|
643
|
-
dateTimeData[point + 'Time'] = timeStr.substring(0, timeStr.length - 3);
|
|
650
|
+
if (dateTimeData[point + 'Time'] && dateTimeData[point + 'Time'].length > 5) {
|
|
651
|
+
dateTimeData[point + 'Time'] = dateTimeData[point + 'Time'].substring(0, 5);
|
|
644
652
|
}
|
|
645
653
|
}
|
|
646
654
|
});
|
|
@@ -685,12 +693,7 @@ function atcb_date_calculation(dateString) {
|
|
|
685
693
|
dateString = dateString.replace(/today/gi, todayString);
|
|
686
694
|
const dateStringParts = dateString.split('+');
|
|
687
695
|
const dateParts = dateStringParts[0].split('-');
|
|
688
|
-
|
|
689
|
-
if (dateParts[0].length < 4) {
|
|
690
|
-
return new Date(Date.UTC(dateParts[2], dateParts[0] - 1, dateParts[1]));
|
|
691
|
-
}
|
|
692
|
-
return new Date(Date.UTC(dateParts[0], dateParts[1] - 1, dateParts[2]));
|
|
693
|
-
})();
|
|
696
|
+
const newDate = new Date(Date.UTC(dateParts[0], dateParts[1] - 1, dateParts[2].substring(0, 2)));
|
|
694
697
|
if (dateStringParts[1] && dateStringParts[1] > 0) {
|
|
695
698
|
newDate.setDate(newDate.getDate() + parseInt(dateStringParts[1]));
|
|
696
699
|
}
|
|
@@ -733,19 +736,25 @@ function atcb_decorate_data_button_status_handling(data) {
|
|
|
733
736
|
return data;
|
|
734
737
|
}
|
|
735
738
|
async function atcb_decorate_data_rsvp(data) {
|
|
736
|
-
if (typeof
|
|
739
|
+
if (typeof atcb_check_bookings !== 'function' || !data.rsvp || !data.proKey || Object.keys(data.rsvp).length === 0) return data;
|
|
737
740
|
data.rsvp.expired = (function () {
|
|
738
741
|
if (data.rsvp && data.rsvp.expires && new Date(data.rsvp.expires) < new Date()) {
|
|
739
742
|
return true;
|
|
740
743
|
}
|
|
741
744
|
return false;
|
|
742
745
|
})();
|
|
743
|
-
data.rsvp.
|
|
744
|
-
|
|
745
|
-
data.
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
746
|
+
if (data.rsvp.max) {
|
|
747
|
+
const bookings = await atcb_check_bookings(data.proKey, data.dev);
|
|
748
|
+
data.rsvp.seatsLeft = data.rsvp.max - bookings;
|
|
749
|
+
if (data.rsvp.seatsLeft < 1) {
|
|
750
|
+
data.rsvp.bookedOut = true;
|
|
751
|
+
}
|
|
752
|
+
if (data.rsvp.expired || data.rsvp.bookedOut) {
|
|
753
|
+
data.blockInteraction = true;
|
|
754
|
+
}
|
|
755
|
+
if (data.blockInteraction) {
|
|
756
|
+
data.disabled = true;
|
|
757
|
+
}
|
|
749
758
|
}
|
|
750
759
|
return data;
|
|
751
760
|
}
|
|
@@ -2139,7 +2148,7 @@ function atcb_generate_subscribe_links(host, linkType, data, keyboardTrigger) {
|
|
|
2139
2148
|
atcb_subscribe_ical(data, data.icsFile);
|
|
2140
2149
|
break;
|
|
2141
2150
|
}
|
|
2142
|
-
atcb_subscribe_ical(data, adjustedFileUrl);
|
|
2151
|
+
atcb_subscribe_ical(data, adjustedFileUrl, host, keyboardTrigger);
|
|
2143
2152
|
break;
|
|
2144
2153
|
case 'google':
|
|
2145
2154
|
atcb_subscribe_google(data, adjustedFileUrl);
|
|
@@ -2208,7 +2217,11 @@ function atcb_set_fully_successful(host, data, multiDateModal = false) {
|
|
|
2208
2217
|
atcb_toggle(host, 'close');
|
|
2209
2218
|
}
|
|
2210
2219
|
}
|
|
2211
|
-
function atcb_subscribe_ical(data, fileUrl) {
|
|
2220
|
+
function atcb_subscribe_ical(data, fileUrl, host = null, keyboardTrigger = false) {
|
|
2221
|
+
if ((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) {
|
|
2222
|
+
atcb_ical_copy_note(host, fileUrl, data, keyboardTrigger);
|
|
2223
|
+
return;
|
|
2224
|
+
}
|
|
2212
2225
|
atcb_open_cal_url(data, 'ical', fileUrl, true);
|
|
2213
2226
|
}
|
|
2214
2227
|
function atcb_subscribe_google(data, fileUrl) {
|
|
@@ -2533,7 +2546,7 @@ function atcb_generate_ical(host, data, subEvent = 'all', keyboardTrigger = fals
|
|
|
2533
2546
|
}
|
|
2534
2547
|
return 'data:text/calendar;charset=utf-8,' + encodeURIComponent(ics_lines.join('\r\n'));
|
|
2535
2548
|
})();
|
|
2536
|
-
if ((atcbIsiOS() && !atcbIsSafari()) || (atcbIsWebView() && (atcbIsiOS() || (atcbIsAndroid() && atcbIsProblematicWebView())))) {
|
|
2549
|
+
if (((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) || (atcbIsWebView() && (atcbIsiOS() || data.fakeIOS || ((atcbIsAndroid() || data.fakeAndroid) && atcbIsProblematicWebView())))) {
|
|
2537
2550
|
atcb_ical_copy_note(host, dataUrl, data, keyboardTrigger);
|
|
2538
2551
|
return;
|
|
2539
2552
|
}
|
|
@@ -2559,7 +2572,7 @@ function atcb_determine_ical_filename(data, subEvent) {
|
|
|
2559
2572
|
}
|
|
2560
2573
|
function atcb_ical_copy_note(host, dataUrl, data, keyboardTrigger) {
|
|
2561
2574
|
atcb_copy_to_clipboard(dataUrl);
|
|
2562
|
-
if (atcbIsiOS() && !atcbIsSafari()) {
|
|
2575
|
+
if ((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) {
|
|
2563
2576
|
atcb_create_modal(
|
|
2564
2577
|
host,
|
|
2565
2578
|
data,
|
|
@@ -4076,27 +4089,26 @@ if (atcbIsBrowser()) {
|
|
|
4076
4089
|
}
|
|
4077
4090
|
this.proOverride = !proOverrideVal || proOverrideVal === 'true' || proOverrideVal === '' ? true : false;
|
|
4078
4091
|
}
|
|
4079
|
-
|
|
4080
|
-
if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
|
|
4081
|
-
this.
|
|
4092
|
+
try {
|
|
4093
|
+
if ((this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') || (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '')) {
|
|
4094
|
+
if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
|
|
4095
|
+
this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
|
|
4096
|
+
} else {
|
|
4097
|
+
this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
|
|
4098
|
+
}
|
|
4099
|
+
if (this.data.proKey) this.proKey = this.data.proKey;
|
|
4082
4100
|
} else {
|
|
4083
|
-
this.data =
|
|
4084
|
-
}
|
|
4085
|
-
if (this.data.proKey) this.proKey = this.data.proKey;
|
|
4086
|
-
}
|
|
4087
|
-
if (!this.data.name || this.data.name === '') {
|
|
4088
|
-
this.data.proKey = '';
|
|
4089
|
-
try {
|
|
4101
|
+
this.data.proKey = '';
|
|
4090
4102
|
this.data = await atcb_process_inline_data(this, this.debug);
|
|
4091
|
-
} catch (e) {
|
|
4092
|
-
if (this.debug) {
|
|
4093
|
-
console.error(e);
|
|
4094
|
-
atcb_render_debug_msg(this.shadowRoot, e);
|
|
4095
|
-
}
|
|
4096
|
-
this.state.initializing = false;
|
|
4097
|
-
this.state.ready = true;
|
|
4098
|
-
return;
|
|
4099
4103
|
}
|
|
4104
|
+
} catch (e) {
|
|
4105
|
+
if (this.debug) {
|
|
4106
|
+
console.error(e);
|
|
4107
|
+
atcb_render_debug_msg(this.shadowRoot, e);
|
|
4108
|
+
}
|
|
4109
|
+
this.state.initializing = false;
|
|
4110
|
+
this.state.ready = true;
|
|
4111
|
+
return;
|
|
4100
4112
|
}
|
|
4101
4113
|
await this.initButton();
|
|
4102
4114
|
this.state.initializing = false;
|
|
@@ -4151,24 +4163,23 @@ if (atcbIsBrowser()) {
|
|
|
4151
4163
|
const elem = document.createElement('template');
|
|
4152
4164
|
elem.innerHTML = template;
|
|
4153
4165
|
this.shadowRoot.append(elem.content.cloneNode(true));
|
|
4154
|
-
|
|
4155
|
-
this.
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
try {
|
|
4166
|
+
try {
|
|
4167
|
+
if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
|
|
4168
|
+
this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
|
|
4169
|
+
if (this.data.proKey) this.proKey = this.data.proKey;
|
|
4170
|
+
} else if (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '') {
|
|
4171
|
+
this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
|
|
4172
|
+
if (this.data.proKey) this.proKey = this.data.proKey;
|
|
4173
|
+
} else {
|
|
4163
4174
|
this.data = await atcb_process_inline_data(this, this.debug);
|
|
4164
|
-
} catch (e) {
|
|
4165
|
-
if (this.debug) {
|
|
4166
|
-
console.error(e);
|
|
4167
|
-
atcb_render_debug_msg(this.shadowRoot, e);
|
|
4168
|
-
}
|
|
4169
|
-
this.updatePending = false;
|
|
4170
|
-
return;
|
|
4171
4175
|
}
|
|
4176
|
+
} catch (e) {
|
|
4177
|
+
if (this.debug) {
|
|
4178
|
+
console.error(e);
|
|
4179
|
+
atcb_render_debug_msg(this.shadowRoot, e);
|
|
4180
|
+
}
|
|
4181
|
+
this.updatePending = false;
|
|
4182
|
+
return;
|
|
4172
4183
|
}
|
|
4173
4184
|
atcb_cleanup(this.shadowRoot, this.identifier);
|
|
4174
4185
|
await this.initButton();
|
|
@@ -4499,19 +4510,28 @@ async function atcb_action(inputData, triggerElement, keyboardTrigger = false) {
|
|
|
4499
4510
|
if (!atcbIsBrowser()) {
|
|
4500
4511
|
return;
|
|
4501
4512
|
}
|
|
4502
|
-
let data
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
cleanedInput
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
const proData = await atcb_get_pro_data(cleanedInput.proKey, null, cleanedInput);
|
|
4509
|
-
if (proData.name && proData.name != '') {
|
|
4510
|
-
return proData;
|
|
4513
|
+
let data;
|
|
4514
|
+
try {
|
|
4515
|
+
data = await (async function () {
|
|
4516
|
+
const cleanedInput = atcb_secure_content(inputData);
|
|
4517
|
+
if (cleanedInput.prokey && cleanedInput.prokey !== '') {
|
|
4518
|
+
cleanedInput.proKey = cleanedInput.prokey;
|
|
4511
4519
|
}
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4520
|
+
if (cleanedInput.proKey && cleanedInput.proKey !== '') {
|
|
4521
|
+
try {
|
|
4522
|
+
const proData = await atcb_get_pro_data(cleanedInput.proKey, null, cleanedInput);
|
|
4523
|
+
return proData;
|
|
4524
|
+
} catch (e) {
|
|
4525
|
+
throw new Error(e.message);
|
|
4526
|
+
}
|
|
4527
|
+
} else {
|
|
4528
|
+
return cleanedInput;
|
|
4529
|
+
}
|
|
4530
|
+
})();
|
|
4531
|
+
} catch (e) {
|
|
4532
|
+
console.error(e);
|
|
4533
|
+
return;
|
|
4534
|
+
}
|
|
4515
4535
|
data.debug = data.debug === 'true';
|
|
4516
4536
|
try {
|
|
4517
4537
|
await atcb_check_required(data);
|
|
@@ -4649,9 +4669,6 @@ async function atcb_get_pro_data(licenseKey, el = null, directData = {}) {
|
|
|
4649
4669
|
const response = await fetch((dataOverrides.dev ? 'https://event-dev.caldn.net/' : 'https://event.caldn.net/') + licenseKey + '/config.json');
|
|
4650
4670
|
if (response.ok) {
|
|
4651
4671
|
const data = await response.json();
|
|
4652
|
-
if (!data.name || data.name === '') {
|
|
4653
|
-
throw new Error('Not possible to read proKey config from server...');
|
|
4654
|
-
}
|
|
4655
4672
|
if (proOverride) {
|
|
4656
4673
|
atcbWcParams.forEach((key) => {
|
|
4657
4674
|
if (Object.prototype.hasOwnProperty.call(dataOverrides, key) && ['hideBranding', 'hidebranding', 'rsvp', 'ty'].indexOf(key) === -1) {
|
|
@@ -4665,13 +4682,16 @@ async function atcb_get_pro_data(licenseKey, el = null, directData = {}) {
|
|
|
4665
4682
|
}
|
|
4666
4683
|
});
|
|
4667
4684
|
}
|
|
4685
|
+
if (!data.name || data.name === '') {
|
|
4686
|
+
throw new Error('Not possible to read proKey config from server...');
|
|
4687
|
+
}
|
|
4668
4688
|
data.proKey = licenseKey;
|
|
4669
4689
|
data.identifier = licenseKey;
|
|
4670
4690
|
return data;
|
|
4671
4691
|
}
|
|
4672
4692
|
throw new Error('Not possible to read proKey config from server...');
|
|
4673
4693
|
} catch {
|
|
4674
|
-
|
|
4694
|
+
throw new Error('Add to Calendar Button proKey invalid or server not responding!');
|
|
4675
4695
|
}
|
|
4676
4696
|
}
|
|
4677
4697
|
return {};
|
|
@@ -6,14 +6,14 @@ const tzlibActions = require('timezones-ical-library');
|
|
|
6
6
|
* Add to Calendar Button
|
|
7
7
|
* ++++++++++++++++++++++
|
|
8
8
|
*
|
|
9
|
-
* Version: 2.
|
|
9
|
+
* Version: 2.7.1
|
|
10
10
|
* Creator: Jens Kuerschner (https://jekuer.com)
|
|
11
11
|
* Project: https://github.com/add2cal/add-to-calendar-button
|
|
12
12
|
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
|
|
13
13
|
* Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
const atcbVersion = '2.
|
|
16
|
+
const atcbVersion = '2.7.1';
|
|
17
17
|
const atcbCssTemplate = {};
|
|
18
18
|
const atcbIsBrowser = () => {
|
|
19
19
|
if (typeof window === 'undefined') {
|
|
@@ -548,8 +548,9 @@ function atcb_decorate_data_description(data, i) {
|
|
|
548
548
|
description = cleanDescription(description);
|
|
549
549
|
if (data.customVar) {
|
|
550
550
|
for (const key in data.customVar) {
|
|
551
|
-
const sanitizedKey = key.replace(/[^\w\-.]/g, '');
|
|
552
|
-
|
|
551
|
+
const sanitizedKey = '%%' + key.replace(/[^\w\-.]/g, '') + '%%';
|
|
552
|
+
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
553
|
+
description = description.replace(new RegExp(sanitizedKey, 'gi'), data.customVar[`${key}`]);
|
|
553
554
|
}
|
|
554
555
|
}
|
|
555
556
|
const descriptionHtmlFree = atcb_rewrite_html_elements(description, true);
|
|
@@ -607,9 +608,11 @@ function atcb_decorate_data_extend(data) {
|
|
|
607
608
|
}
|
|
608
609
|
if (data.customVar) {
|
|
609
610
|
for (const key in data.customVar) {
|
|
610
|
-
const sanitizedKey = key.replace(/[^\w\-.]/g, '');
|
|
611
|
-
|
|
612
|
-
data.dates[`${i}`].
|
|
611
|
+
const sanitizedKey = '%%' + key.replace(/[^\w\-.]/g, '') + '%%';
|
|
612
|
+
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
613
|
+
data.dates[`${i}`].name = data.dates[`${i}`].name.replace(new RegExp(sanitizedKey, 'gi'), data.customVar[`${key}`]);
|
|
614
|
+
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
615
|
+
data.dates[`${i}`].location = data.dates[`${i}`].location.replace(new RegExp(sanitizedKey, 'gi'), data.customVar[`${key}`]);
|
|
613
616
|
}
|
|
614
617
|
}
|
|
615
618
|
}
|
|
@@ -622,26 +625,31 @@ function atcb_decorate_data_extend(data) {
|
|
|
622
625
|
return data;
|
|
623
626
|
}
|
|
624
627
|
function atcb_date_cleanup(dateTimeData) {
|
|
628
|
+
function isValidDateFormat(dateStr) {
|
|
629
|
+
return /^\d\d\d\d-\d\d-\d\d(?:T\d\d:\d\d)?(?::\d\d)?(?:.\d\d\d)?Z?$/i.test(dateStr);
|
|
630
|
+
}
|
|
631
|
+
function isValidTodayFormat(dateStr) {
|
|
632
|
+
return /^today(?:\+(?:\d|\d\d|\d\d\d|\d\d\d\d))?$/i.test(dateStr);
|
|
633
|
+
}
|
|
625
634
|
if (!dateTimeData.endDate || dateTimeData.endDate === '') {
|
|
626
635
|
dateTimeData.endDate = dateTimeData.startDate;
|
|
627
636
|
}
|
|
628
637
|
const endpoints = ['start', 'end'];
|
|
629
638
|
endpoints.forEach(function (point) {
|
|
630
|
-
|
|
639
|
+
const dateStr = dateTimeData[point + 'Date'];
|
|
640
|
+
if (!isValidDateFormat(dateStr) && !isValidTodayFormat(dateStr)) {
|
|
631
641
|
dateTimeData[point + 'Date'] = 'badly-formed';
|
|
632
642
|
} else {
|
|
633
|
-
dateTimeData[point + 'Date'] = atcb_date_calculation(
|
|
643
|
+
if (isValidTodayFormat(dateStr)) dateTimeData[point + 'Date'] = atcb_date_calculation(dateStr);
|
|
634
644
|
if (dateTimeData[point + 'Date']) {
|
|
635
|
-
dateTimeData[point + 'Date'] = dateTimeData[point + 'Date'].replace(/\.\d{3}/, '').replace('Z', '');
|
|
636
645
|
const tmpSplitStartDate = dateTimeData[point + 'Date'].split('T');
|
|
637
646
|
if (tmpSplitStartDate[1]) {
|
|
638
647
|
dateTimeData[point + 'Date'] = tmpSplitStartDate[0];
|
|
639
648
|
dateTimeData[point + 'Time'] = tmpSplitStartDate[1];
|
|
640
649
|
}
|
|
641
650
|
}
|
|
642
|
-
if (dateTimeData[point + 'Time'] && dateTimeData[point + 'Time'].length
|
|
643
|
-
|
|
644
|
-
dateTimeData[point + 'Time'] = timeStr.substring(0, timeStr.length - 3);
|
|
651
|
+
if (dateTimeData[point + 'Time'] && dateTimeData[point + 'Time'].length > 5) {
|
|
652
|
+
dateTimeData[point + 'Time'] = dateTimeData[point + 'Time'].substring(0, 5);
|
|
645
653
|
}
|
|
646
654
|
}
|
|
647
655
|
});
|
|
@@ -686,12 +694,7 @@ function atcb_date_calculation(dateString) {
|
|
|
686
694
|
dateString = dateString.replace(/today/gi, todayString);
|
|
687
695
|
const dateStringParts = dateString.split('+');
|
|
688
696
|
const dateParts = dateStringParts[0].split('-');
|
|
689
|
-
|
|
690
|
-
if (dateParts[0].length < 4) {
|
|
691
|
-
return new Date(Date.UTC(dateParts[2], dateParts[0] - 1, dateParts[1]));
|
|
692
|
-
}
|
|
693
|
-
return new Date(Date.UTC(dateParts[0], dateParts[1] - 1, dateParts[2]));
|
|
694
|
-
})();
|
|
697
|
+
const newDate = new Date(Date.UTC(dateParts[0], dateParts[1] - 1, dateParts[2].substring(0, 2)));
|
|
695
698
|
if (dateStringParts[1] && dateStringParts[1] > 0) {
|
|
696
699
|
newDate.setDate(newDate.getDate() + parseInt(dateStringParts[1]));
|
|
697
700
|
}
|
|
@@ -734,19 +737,25 @@ function atcb_decorate_data_button_status_handling(data) {
|
|
|
734
737
|
return data;
|
|
735
738
|
}
|
|
736
739
|
async function atcb_decorate_data_rsvp(data) {
|
|
737
|
-
if (typeof
|
|
740
|
+
if (typeof atcb_check_bookings !== 'function' || !data.rsvp || !data.proKey || Object.keys(data.rsvp).length === 0) return data;
|
|
738
741
|
data.rsvp.expired = (function () {
|
|
739
742
|
if (data.rsvp && data.rsvp.expires && new Date(data.rsvp.expires) < new Date()) {
|
|
740
743
|
return true;
|
|
741
744
|
}
|
|
742
745
|
return false;
|
|
743
746
|
})();
|
|
744
|
-
data.rsvp.
|
|
745
|
-
|
|
746
|
-
data.
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
747
|
+
if (data.rsvp.max) {
|
|
748
|
+
const bookings = await atcb_check_bookings(data.proKey, data.dev);
|
|
749
|
+
data.rsvp.seatsLeft = data.rsvp.max - bookings;
|
|
750
|
+
if (data.rsvp.seatsLeft < 1) {
|
|
751
|
+
data.rsvp.bookedOut = true;
|
|
752
|
+
}
|
|
753
|
+
if (data.rsvp.expired || data.rsvp.bookedOut) {
|
|
754
|
+
data.blockInteraction = true;
|
|
755
|
+
}
|
|
756
|
+
if (data.blockInteraction) {
|
|
757
|
+
data.disabled = true;
|
|
758
|
+
}
|
|
750
759
|
}
|
|
751
760
|
return data;
|
|
752
761
|
}
|
|
@@ -2140,7 +2149,7 @@ function atcb_generate_subscribe_links(host, linkType, data, keyboardTrigger) {
|
|
|
2140
2149
|
atcb_subscribe_ical(data, data.icsFile);
|
|
2141
2150
|
break;
|
|
2142
2151
|
}
|
|
2143
|
-
atcb_subscribe_ical(data, adjustedFileUrl);
|
|
2152
|
+
atcb_subscribe_ical(data, adjustedFileUrl, host, keyboardTrigger);
|
|
2144
2153
|
break;
|
|
2145
2154
|
case 'google':
|
|
2146
2155
|
atcb_subscribe_google(data, adjustedFileUrl);
|
|
@@ -2209,7 +2218,11 @@ function atcb_set_fully_successful(host, data, multiDateModal = false) {
|
|
|
2209
2218
|
atcb_toggle(host, 'close');
|
|
2210
2219
|
}
|
|
2211
2220
|
}
|
|
2212
|
-
function atcb_subscribe_ical(data, fileUrl) {
|
|
2221
|
+
function atcb_subscribe_ical(data, fileUrl, host = null, keyboardTrigger = false) {
|
|
2222
|
+
if ((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) {
|
|
2223
|
+
atcb_ical_copy_note(host, fileUrl, data, keyboardTrigger);
|
|
2224
|
+
return;
|
|
2225
|
+
}
|
|
2213
2226
|
atcb_open_cal_url(data, 'ical', fileUrl, true);
|
|
2214
2227
|
}
|
|
2215
2228
|
function atcb_subscribe_google(data, fileUrl) {
|
|
@@ -2534,7 +2547,7 @@ function atcb_generate_ical(host, data, subEvent = 'all', keyboardTrigger = fals
|
|
|
2534
2547
|
}
|
|
2535
2548
|
return 'data:text/calendar;charset=utf-8,' + encodeURIComponent(ics_lines.join('\r\n'));
|
|
2536
2549
|
})();
|
|
2537
|
-
if ((atcbIsiOS() && !atcbIsSafari()) || (atcbIsWebView() && (atcbIsiOS() || (atcbIsAndroid() && atcbIsProblematicWebView())))) {
|
|
2550
|
+
if (((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) || (atcbIsWebView() && (atcbIsiOS() || data.fakeIOS || ((atcbIsAndroid() || data.fakeAndroid) && atcbIsProblematicWebView())))) {
|
|
2538
2551
|
atcb_ical_copy_note(host, dataUrl, data, keyboardTrigger);
|
|
2539
2552
|
return;
|
|
2540
2553
|
}
|
|
@@ -2560,7 +2573,7 @@ function atcb_determine_ical_filename(data, subEvent) {
|
|
|
2560
2573
|
}
|
|
2561
2574
|
function atcb_ical_copy_note(host, dataUrl, data, keyboardTrigger) {
|
|
2562
2575
|
atcb_copy_to_clipboard(dataUrl);
|
|
2563
|
-
if (atcbIsiOS() && !atcbIsSafari()) {
|
|
2576
|
+
if ((atcbIsiOS() || data.fakeIOS) && !atcbIsSafari()) {
|
|
2564
2577
|
atcb_create_modal(
|
|
2565
2578
|
host,
|
|
2566
2579
|
data,
|
|
@@ -4077,27 +4090,26 @@ if (atcbIsBrowser()) {
|
|
|
4077
4090
|
}
|
|
4078
4091
|
this.proOverride = !proOverrideVal || proOverrideVal === 'true' || proOverrideVal === '' ? true : false;
|
|
4079
4092
|
}
|
|
4080
|
-
|
|
4081
|
-
if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
|
|
4082
|
-
this.
|
|
4093
|
+
try {
|
|
4094
|
+
if ((this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') || (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '')) {
|
|
4095
|
+
if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
|
|
4096
|
+
this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
|
|
4097
|
+
} else {
|
|
4098
|
+
this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
|
|
4099
|
+
}
|
|
4100
|
+
if (this.data.proKey) this.proKey = this.data.proKey;
|
|
4083
4101
|
} else {
|
|
4084
|
-
this.data =
|
|
4085
|
-
}
|
|
4086
|
-
if (this.data.proKey) this.proKey = this.data.proKey;
|
|
4087
|
-
}
|
|
4088
|
-
if (!this.data.name || this.data.name === '') {
|
|
4089
|
-
this.data.proKey = '';
|
|
4090
|
-
try {
|
|
4102
|
+
this.data.proKey = '';
|
|
4091
4103
|
this.data = await atcb_process_inline_data(this, this.debug);
|
|
4092
|
-
} catch (e) {
|
|
4093
|
-
if (this.debug) {
|
|
4094
|
-
console.error(e);
|
|
4095
|
-
atcb_render_debug_msg(this.shadowRoot, e);
|
|
4096
|
-
}
|
|
4097
|
-
this.state.initializing = false;
|
|
4098
|
-
this.state.ready = true;
|
|
4099
|
-
return;
|
|
4100
4104
|
}
|
|
4105
|
+
} catch (e) {
|
|
4106
|
+
if (this.debug) {
|
|
4107
|
+
console.error(e);
|
|
4108
|
+
atcb_render_debug_msg(this.shadowRoot, e);
|
|
4109
|
+
}
|
|
4110
|
+
this.state.initializing = false;
|
|
4111
|
+
this.state.ready = true;
|
|
4112
|
+
return;
|
|
4101
4113
|
}
|
|
4102
4114
|
await this.initButton();
|
|
4103
4115
|
this.state.initializing = false;
|
|
@@ -4152,24 +4164,23 @@ if (atcbIsBrowser()) {
|
|
|
4152
4164
|
const elem = document.createElement('template');
|
|
4153
4165
|
elem.innerHTML = template;
|
|
4154
4166
|
this.shadowRoot.append(elem.content.cloneNode(true));
|
|
4155
|
-
|
|
4156
|
-
this.
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
try {
|
|
4167
|
+
try {
|
|
4168
|
+
if (this.hasAttribute('proKey') && this.getAttribute('proKey') !== '') {
|
|
4169
|
+
this.data = await atcb_get_pro_data(this.getAttribute('proKey'), this);
|
|
4170
|
+
if (this.data.proKey) this.proKey = this.data.proKey;
|
|
4171
|
+
} else if (this.hasAttribute('prokey') && this.getAttribute('prokey') !== '') {
|
|
4172
|
+
this.data = await atcb_get_pro_data(this.getAttribute('prokey'), this);
|
|
4173
|
+
if (this.data.proKey) this.proKey = this.data.proKey;
|
|
4174
|
+
} else {
|
|
4164
4175
|
this.data = await atcb_process_inline_data(this, this.debug);
|
|
4165
|
-
} catch (e) {
|
|
4166
|
-
if (this.debug) {
|
|
4167
|
-
console.error(e);
|
|
4168
|
-
atcb_render_debug_msg(this.shadowRoot, e);
|
|
4169
|
-
}
|
|
4170
|
-
this.updatePending = false;
|
|
4171
|
-
return;
|
|
4172
4176
|
}
|
|
4177
|
+
} catch (e) {
|
|
4178
|
+
if (this.debug) {
|
|
4179
|
+
console.error(e);
|
|
4180
|
+
atcb_render_debug_msg(this.shadowRoot, e);
|
|
4181
|
+
}
|
|
4182
|
+
this.updatePending = false;
|
|
4183
|
+
return;
|
|
4173
4184
|
}
|
|
4174
4185
|
atcb_cleanup(this.shadowRoot, this.identifier);
|
|
4175
4186
|
await this.initButton();
|
|
@@ -4500,19 +4511,28 @@ async function atcb_action(inputData, triggerElement, keyboardTrigger = false) {
|
|
|
4500
4511
|
if (!atcbIsBrowser()) {
|
|
4501
4512
|
return;
|
|
4502
4513
|
}
|
|
4503
|
-
let data
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
cleanedInput
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
const proData = await atcb_get_pro_data(cleanedInput.proKey, null, cleanedInput);
|
|
4510
|
-
if (proData.name && proData.name != '') {
|
|
4511
|
-
return proData;
|
|
4514
|
+
let data;
|
|
4515
|
+
try {
|
|
4516
|
+
data = await (async function () {
|
|
4517
|
+
const cleanedInput = atcb_secure_content(inputData);
|
|
4518
|
+
if (cleanedInput.prokey && cleanedInput.prokey !== '') {
|
|
4519
|
+
cleanedInput.proKey = cleanedInput.prokey;
|
|
4512
4520
|
}
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4521
|
+
if (cleanedInput.proKey && cleanedInput.proKey !== '') {
|
|
4522
|
+
try {
|
|
4523
|
+
const proData = await atcb_get_pro_data(cleanedInput.proKey, null, cleanedInput);
|
|
4524
|
+
return proData;
|
|
4525
|
+
} catch (e) {
|
|
4526
|
+
throw new Error(e.message);
|
|
4527
|
+
}
|
|
4528
|
+
} else {
|
|
4529
|
+
return cleanedInput;
|
|
4530
|
+
}
|
|
4531
|
+
})();
|
|
4532
|
+
} catch (e) {
|
|
4533
|
+
console.error(e);
|
|
4534
|
+
return;
|
|
4535
|
+
}
|
|
4516
4536
|
data.debug = data.debug === 'true';
|
|
4517
4537
|
try {
|
|
4518
4538
|
await atcb_check_required(data);
|
|
@@ -4650,9 +4670,6 @@ async function atcb_get_pro_data(licenseKey, el = null, directData = {}) {
|
|
|
4650
4670
|
const response = await fetch((dataOverrides.dev ? 'https://event-dev.caldn.net/' : 'https://event.caldn.net/') + licenseKey + '/config.json');
|
|
4651
4671
|
if (response.ok) {
|
|
4652
4672
|
const data = await response.json();
|
|
4653
|
-
if (!data.name || data.name === '') {
|
|
4654
|
-
throw new Error('Not possible to read proKey config from server...');
|
|
4655
|
-
}
|
|
4656
4673
|
if (proOverride) {
|
|
4657
4674
|
atcbWcParams.forEach((key) => {
|
|
4658
4675
|
if (Object.prototype.hasOwnProperty.call(dataOverrides, key) && ['hideBranding', 'hidebranding', 'rsvp', 'ty'].indexOf(key) === -1) {
|
|
@@ -4666,13 +4683,16 @@ async function atcb_get_pro_data(licenseKey, el = null, directData = {}) {
|
|
|
4666
4683
|
}
|
|
4667
4684
|
});
|
|
4668
4685
|
}
|
|
4686
|
+
if (!data.name || data.name === '') {
|
|
4687
|
+
throw new Error('Not possible to read proKey config from server...');
|
|
4688
|
+
}
|
|
4669
4689
|
data.proKey = licenseKey;
|
|
4670
4690
|
data.identifier = licenseKey;
|
|
4671
4691
|
return data;
|
|
4672
4692
|
}
|
|
4673
4693
|
throw new Error('Not possible to read proKey config from server...');
|
|
4674
4694
|
} catch {
|
|
4675
|
-
|
|
4695
|
+
throw new Error('Add to Calendar Button proKey invalid or server not responding!');
|
|
4676
4696
|
}
|
|
4677
4697
|
}
|
|
4678
4698
|
return {};
|