nodebb-plugin-onekite-calendar 2.0.69 → 2.0.71
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/lib/discord.js +4 -4
- package/lib/shared.js +1 -0
- package/lib/widgets.js +1 -2
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/public/client.js +18 -5
package/lib/discord.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const https = require('https');
|
|
4
4
|
const { URL } = require('url');
|
|
5
|
-
const { formatFRShort } = require('./shared');
|
|
5
|
+
const { formatFRShort, forumBaseUrl } = require('./shared');
|
|
6
6
|
|
|
7
7
|
function isEnabled(v, defaultValue) {
|
|
8
8
|
if (v === undefined || v === null || v === '') return defaultValue !== false;
|
|
@@ -53,7 +53,7 @@ function postWebhook(webhookUrl, payload) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
function buildReservationMessage(kind, reservation) {
|
|
56
|
-
const calUrl = '
|
|
56
|
+
const calUrl = forumBaseUrl() + '/calendar';
|
|
57
57
|
const username = reservation && reservation.username ? String(reservation.username) : '';
|
|
58
58
|
const items = (reservation && Array.isArray(reservation.itemNames) && reservation.itemNames.length)
|
|
59
59
|
? reservation.itemNames.map(String)
|
|
@@ -87,7 +87,7 @@ function buildWebhookPayload(kind, reservation) {
|
|
|
87
87
|
? 'Onekite • Paiement'
|
|
88
88
|
: (kind === 'cancelled' ? 'Onekite • Annulation' : 'Onekite • Réservation');
|
|
89
89
|
|
|
90
|
-
const calUrl = '
|
|
90
|
+
const calUrl = forumBaseUrl() + '/calendar';
|
|
91
91
|
const username = reservation && reservation.username ? String(reservation.username) : '';
|
|
92
92
|
const items = (reservation && Array.isArray(reservation.itemNames) && reservation.itemNames.length)
|
|
93
93
|
? reservation.itemNames.map(String)
|
|
@@ -186,7 +186,7 @@ async function notifyReservationCancelled(settings, reservation) {
|
|
|
186
186
|
|
|
187
187
|
function buildSimpleCalendarPayload(kind, label, entity, opts) {
|
|
188
188
|
const options = opts || {};
|
|
189
|
-
const calUrl = options.calUrl || '
|
|
189
|
+
const calUrl = options.calUrl || forumBaseUrl() + '/calendar';
|
|
190
190
|
const webhookUsername = options.webhookUsername || `Onekite • ${label}`;
|
|
191
191
|
|
|
192
192
|
const title = kind === 'deleted' ? '❌ ' + label + ' annulé(e)' : label + ' créé(e)';
|
package/lib/shared.js
CHANGED
package/lib/widgets.js
CHANGED
package/package.json
CHANGED
package/plugin.json
CHANGED
package/public/client.js
CHANGED
|
@@ -169,6 +169,13 @@ define('forum/calendar-onekite', ['alerts', 'bootbox', 'hooks'], function (alert
|
|
|
169
169
|
.replace(/'/g, ''');
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
function linkifyNotes(str) {
|
|
173
|
+
return escapeHtml(str).replace(
|
|
174
|
+
/https?:\/\/[^\s<>"']+/g,
|
|
175
|
+
url => `<a href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
172
179
|
function getCsrfToken() {
|
|
173
180
|
try {
|
|
174
181
|
return (
|
|
@@ -1266,8 +1273,14 @@ function toDatetimeLocalValue(date) {
|
|
|
1266
1273
|
}
|
|
1267
1274
|
|
|
1268
1275
|
if (typeof FullCalendar === 'undefined') {
|
|
1269
|
-
|
|
1270
|
-
|
|
1276
|
+
const loaded = await new Promise((resolve) => {
|
|
1277
|
+
const start = Date.now();
|
|
1278
|
+
const iv = setInterval(() => {
|
|
1279
|
+
if (typeof FullCalendar !== 'undefined') { clearInterval(iv); resolve(true); }
|
|
1280
|
+
else if (Date.now() - start > 5000) { clearInterval(iv); resolve(false); }
|
|
1281
|
+
}, 50);
|
|
1282
|
+
});
|
|
1283
|
+
if (!loaded) { showAlert('error', 'FullCalendar non chargé'); return; }
|
|
1271
1284
|
}
|
|
1272
1285
|
|
|
1273
1286
|
const items = await loadItems();
|
|
@@ -1803,7 +1816,7 @@ function toDatetimeLocalValue(date) {
|
|
|
1803
1816
|
${calHtml}
|
|
1804
1817
|
${participantsHtml}
|
|
1805
1818
|
${addr ? `<div class="mb-2"><strong>Adresse</strong><br>${addrHtml}</div>` : ''}
|
|
1806
|
-
${notes ? `<div class="mb-2"><strong>Notes</strong><br>${
|
|
1819
|
+
${notes ? `<div class="mb-2"><strong>Notes</strong><br>${linkifyNotes(notes).replace(/\n/g,'<br>')}</div>` : ''}
|
|
1807
1820
|
`;
|
|
1808
1821
|
const canDel = !!(p.canDeleteSpecial || canDeleteSpecial);
|
|
1809
1822
|
const canEdit = !!p.canEditSpecial;
|
|
@@ -1981,7 +1994,7 @@ function toDatetimeLocalValue(date) {
|
|
|
1981
1994
|
${calHtml}
|
|
1982
1995
|
${participantsHtml}
|
|
1983
1996
|
${addr ? `<div class="mb-2"><strong>Adresse</strong><br>${addrHtml}</div>` : ''}
|
|
1984
|
-
${notes ? `<div class="mb-2"><strong>Notes</strong><br>${
|
|
1997
|
+
${notes ? `<div class="mb-2"><strong>Notes</strong><br>${linkifyNotes(notes).replace(/\n/g,'<br>')}</div>` : ''}
|
|
1985
1998
|
`;
|
|
1986
1999
|
const canDel = !!(p.canDeleteOuting);
|
|
1987
2000
|
const canEditOuting = !!p.canEditOuting;
|
|
@@ -2154,7 +2167,7 @@ function toDatetimeLocalValue(date) {
|
|
|
2154
2167
|
${pickupAddress ? `${escapeHtml(pickupAddress)}<br>` : ''}
|
|
2155
2168
|
${pickupTime ? `Heure : ${escapeHtml(pickupTime)}<br>` : ''}
|
|
2156
2169
|
${hasCoords ? `<a href="${osmLink}" target="_blank" rel="noopener">Voir sur la carte</a><br>` : ''}
|
|
2157
|
-
${notes ? `<div class="mt-1"><strong>Notes</strong><br>${
|
|
2170
|
+
${notes ? `<div class="mt-1"><strong>Notes</strong><br>${linkifyNotes(notes).replace(/\n/g,'<br>')}</div>` : ''}
|
|
2158
2171
|
</div>
|
|
2159
2172
|
`
|
|
2160
2173
|
: '';
|