@hebcal/rest-api 4.3.5 → 4.3.7
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 +1 -1
- package/dist/bundle.js +79 -192
- package/dist/bundle.min.js +2 -2
- package/dist/fullcalendar.js +14 -57
- package/dist/fullcalendar.min.js +2 -2
- package/dist/index.js +30 -143
- package/dist/index.mjs +30 -141
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/*! @hebcal/rest-api v4.3.
|
|
1
|
+
/*! @hebcal/rest-api v4.3.7 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
4
|
var core = require('@hebcal/core');
|
|
7
5
|
var leyning = require('@hebcal/leyning');
|
|
8
6
|
var triennial = require('@hebcal/triennial');
|
|
@@ -15,7 +13,6 @@ var AD="Andorra";var AE="United Arab Emirates";var AF="Afghanistan";var AI="Angu
|
|
|
15
13
|
* @param {Location} location
|
|
16
14
|
* @return {string}
|
|
17
15
|
*/
|
|
18
|
-
|
|
19
16
|
function locationToPlainObj(location) {
|
|
20
17
|
if (typeof location === 'object' && location !== null && typeof location.name === 'string') {
|
|
21
18
|
const o = {
|
|
@@ -39,6 +36,7 @@ function locationToPlainObj(location) {
|
|
|
39
36
|
};
|
|
40
37
|
}
|
|
41
38
|
}
|
|
39
|
+
|
|
42
40
|
/**
|
|
43
41
|
* Helper function to transform a string to make it more usable in a URL or filename.
|
|
44
42
|
* Converts to lowercase and replaces non-word characters with hyphen ('-').
|
|
@@ -47,25 +45,21 @@ function locationToPlainObj(location) {
|
|
|
47
45
|
* @param {string} s
|
|
48
46
|
* @return {string}
|
|
49
47
|
*/
|
|
50
|
-
|
|
51
48
|
function makeAnchor(s) {
|
|
52
49
|
return s.toLowerCase().replace(/'/g, '').replace(/[^\w]/g, '-').replace(/-+/g, '-').replace(/^-/g, '').replace(/-$/g, '');
|
|
53
50
|
}
|
|
51
|
+
|
|
54
52
|
/**
|
|
55
53
|
* @param {CalOptions} options
|
|
56
54
|
* @return {string}
|
|
57
55
|
*/
|
|
58
|
-
|
|
59
56
|
function getDownloadFilename(options) {
|
|
60
57
|
let fileName = 'hebcal';
|
|
61
|
-
|
|
62
58
|
if (options.year) {
|
|
63
59
|
fileName += '_' + options.year;
|
|
64
|
-
|
|
65
60
|
if (options.isHebrewYear) {
|
|
66
61
|
fileName += 'h';
|
|
67
62
|
}
|
|
68
|
-
|
|
69
63
|
if (options.month) {
|
|
70
64
|
fileName += '_' + options.month;
|
|
71
65
|
}
|
|
@@ -74,42 +68,37 @@ function getDownloadFilename(options) {
|
|
|
74
68
|
const end = new core.HDate(options.end);
|
|
75
69
|
const y1 = start.greg().getFullYear();
|
|
76
70
|
const y2 = end.greg().getFullYear();
|
|
77
|
-
|
|
78
71
|
if (y1 === y2) {
|
|
79
72
|
fileName += '_' + y1;
|
|
80
73
|
} else {
|
|
81
74
|
fileName += '_' + y1 + '_' + y2;
|
|
82
75
|
}
|
|
83
76
|
}
|
|
84
|
-
|
|
85
77
|
if (typeof options.location === 'object') {
|
|
86
78
|
const loc = options.location;
|
|
87
79
|
const name = loc.zip || loc.asciiname || loc.getShortName();
|
|
88
|
-
|
|
89
80
|
if (name) {
|
|
90
81
|
fileName += '_' + makeAnchor(name).replace(/[-]/g, '_');
|
|
91
82
|
}
|
|
92
83
|
}
|
|
93
|
-
|
|
94
84
|
return fileName;
|
|
95
85
|
}
|
|
86
|
+
|
|
96
87
|
/**
|
|
97
88
|
* @param {number} number
|
|
98
89
|
* @return {string}
|
|
99
90
|
*/
|
|
100
|
-
|
|
101
91
|
function pad2(number) {
|
|
102
92
|
if (number < 10) {
|
|
103
93
|
return '0' + number;
|
|
104
94
|
}
|
|
105
|
-
|
|
106
95
|
return '' + number;
|
|
107
96
|
}
|
|
97
|
+
|
|
108
98
|
/**
|
|
109
99
|
* @param {number} number
|
|
110
100
|
* @return {string}
|
|
111
101
|
*/
|
|
112
|
-
|
|
113
102
|
function pad4(number) {
|
|
114
103
|
if (number < 0) {
|
|
115
104
|
return '-00' + pad4(-number);
|
|
@@ -120,59 +109,51 @@ function pad4(number) {
|
|
|
120
109
|
} else if (number < 1000) {
|
|
121
110
|
return '0' + number;
|
|
122
111
|
}
|
|
123
|
-
|
|
124
112
|
return '' + number;
|
|
125
113
|
}
|
|
114
|
+
|
|
126
115
|
/**
|
|
127
116
|
* Returns just the date portion as YYYY-MM-DD
|
|
128
117
|
* @param {Date} d
|
|
129
118
|
* @return {string}
|
|
130
119
|
*/
|
|
131
|
-
|
|
132
120
|
function toISOString(d) {
|
|
133
121
|
return pad4(d.getFullYear()) + '-' + pad2(d.getMonth() + 1) + '-' + pad2(d.getDate());
|
|
134
122
|
}
|
|
135
|
-
const flagToCategory = [[core.flags.MAJOR_FAST, 'holiday', 'major', 'fast'], [core.flags.CHANUKAH_CANDLES, 'holiday', 'major'], [core.flags.DAF_YOMI, 'dafyomi'], [core.flags.HEBREW_DATE, 'hebdate'], [core.flags.MINOR_FAST, 'holiday', 'fast'], [core.flags.MINOR_HOLIDAY, 'holiday', 'minor'], [core.flags.MISHNA_YOMI, 'mishnayomi'], [core.flags.MODERN_HOLIDAY, 'holiday', 'modern'], [core.flags.MOLAD, 'molad'], [core.flags.OMER_COUNT, 'omer'], [core.flags.PARSHA_HASHAVUA, 'parashat'],
|
|
123
|
+
const flagToCategory = [[core.flags.MAJOR_FAST, 'holiday', 'major', 'fast'], [core.flags.CHANUKAH_CANDLES, 'holiday', 'major'], [core.flags.DAF_YOMI, 'dafyomi'], [core.flags.HEBREW_DATE, 'hebdate'], [core.flags.MINOR_FAST, 'holiday', 'fast'], [core.flags.MINOR_HOLIDAY, 'holiday', 'minor'], [core.flags.MISHNA_YOMI, 'mishnayomi'], [core.flags.YERUSHALMI_YOMI, 'yerushalmi'], [core.flags.MODERN_HOLIDAY, 'holiday', 'modern'], [core.flags.MOLAD, 'molad'], [core.flags.OMER_COUNT, 'omer'], [core.flags.PARSHA_HASHAVUA, 'parashat'],
|
|
124
|
+
// backwards-compat
|
|
136
125
|
[core.flags.ROSH_CHODESH, 'roshchodesh'], [core.flags.SHABBAT_MEVARCHIM, 'mevarchim'], [core.flags.SPECIAL_SHABBAT, 'holiday', 'shabbat'], [core.flags.USER_EVENT, 'user']];
|
|
126
|
+
|
|
137
127
|
/**
|
|
138
128
|
* Returns a category and subcategory name
|
|
139
129
|
* @param {Event} ev
|
|
140
130
|
* @return {string[]}
|
|
141
131
|
*/
|
|
142
|
-
|
|
143
132
|
function getEventCategories(ev) {
|
|
144
133
|
const desc = ev.getDesc();
|
|
145
|
-
|
|
146
134
|
switch (desc) {
|
|
147
135
|
// LIGHT_CANDLES or LIGHT_CANDLES_TZEIS
|
|
148
136
|
case 'Candle lighting':
|
|
149
137
|
return ['candles'];
|
|
150
138
|
// YOM_TOV_ENDS
|
|
151
|
-
|
|
152
139
|
case 'Havdalah':
|
|
153
140
|
return ['havdalah'];
|
|
154
141
|
// flags.MINOR_FAST or flags.MAJOR_FAST
|
|
155
|
-
|
|
156
142
|
case 'Fast begins':
|
|
157
143
|
case 'Fast ends':
|
|
158
144
|
return ['zmanim', 'fast'];
|
|
159
145
|
}
|
|
160
|
-
|
|
161
146
|
if (ev.cholHaMoedDay) {
|
|
162
147
|
return ['holiday', 'major', 'cholhamoed'];
|
|
163
148
|
}
|
|
164
|
-
|
|
165
149
|
const mask = ev.getFlags();
|
|
166
|
-
|
|
167
150
|
for (let i = 0; i < flagToCategory.length; i++) {
|
|
168
151
|
const attrs = flagToCategory[i];
|
|
169
|
-
|
|
170
152
|
if (mask & attrs[0]) {
|
|
171
153
|
return attrs.slice(1);
|
|
172
154
|
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
155
|
+
}
|
|
156
|
+
// Don't depend on flags.MINOR_HOLIDAY always being set
|
|
176
157
|
switch (desc) {
|
|
177
158
|
case 'Lag BaOmer':
|
|
178
159
|
case 'Leil Selichot':
|
|
@@ -184,31 +165,29 @@ function getEventCategories(ev) {
|
|
|
184
165
|
case 'Tu BiShvat':
|
|
185
166
|
case 'Rosh Hashana LaBehemot':
|
|
186
167
|
return ['holiday', 'minor'];
|
|
187
|
-
|
|
188
168
|
default:
|
|
189
169
|
return ['holiday', 'major'];
|
|
190
170
|
}
|
|
191
171
|
}
|
|
172
|
+
|
|
192
173
|
/**
|
|
193
174
|
* Renders the event title in default locale, but strips off time
|
|
194
175
|
* @param {Event} ev
|
|
195
176
|
* @return {string}
|
|
196
177
|
*/
|
|
197
|
-
|
|
198
178
|
function renderTitleWithoutTime(ev) {
|
|
199
179
|
return typeof ev.eventTime === 'undefined' ? ev.render() : ev.renderBrief();
|
|
200
180
|
}
|
|
181
|
+
|
|
201
182
|
/**
|
|
202
183
|
* Generates a title like "Hebcal 2020 Israel" or "Hebcal May 1993 Providence"
|
|
203
184
|
* @param {Event[]} events
|
|
204
185
|
* @param {CalOptions} options
|
|
205
186
|
* @return {string}
|
|
206
187
|
*/
|
|
207
|
-
|
|
208
188
|
function getCalendarTitle(events, options) {
|
|
209
189
|
let title = 'Hebcal';
|
|
210
190
|
const location = options.location;
|
|
211
|
-
|
|
212
191
|
if (options.yahrzeit) {
|
|
213
192
|
title += ' Yahrzeits and Anniversaries';
|
|
214
193
|
} else if (location && location.name) {
|
|
@@ -220,17 +199,14 @@ function getCalendarTitle(events, options) {
|
|
|
220
199
|
} else {
|
|
221
200
|
title += ' Diaspora';
|
|
222
201
|
}
|
|
223
|
-
|
|
224
202
|
if (options.subscribe == '1') {
|
|
225
203
|
return title;
|
|
226
204
|
}
|
|
227
|
-
|
|
228
205
|
if (options.year && (options.isHebrewYear || events.length == 0)) {
|
|
229
206
|
title += ' ' + options.year;
|
|
230
207
|
} else if (events.length) {
|
|
231
208
|
const start = events[0].getDate().greg();
|
|
232
209
|
const end = events[events.length - 1].getDate().greg();
|
|
233
|
-
|
|
234
210
|
if (start.getFullYear() != end.getFullYear()) {
|
|
235
211
|
title += ' ' + start.getFullYear() + '-' + end.getFullYear();
|
|
236
212
|
} else if (start.getMonth() == end.getMonth()) {
|
|
@@ -243,71 +219,62 @@ function getCalendarTitle(events, options) {
|
|
|
243
219
|
title += ' ' + start.getFullYear();
|
|
244
220
|
}
|
|
245
221
|
}
|
|
246
|
-
|
|
247
222
|
return title;
|
|
248
223
|
}
|
|
224
|
+
|
|
249
225
|
/**
|
|
250
226
|
* Returns an English language description of the holiday
|
|
251
227
|
* @param {Event} ev
|
|
252
228
|
* @param {boolean} [firstSentence=false]
|
|
253
229
|
* @return {string}
|
|
254
230
|
*/
|
|
255
|
-
|
|
256
231
|
function getHolidayDescription(ev, firstSentence = false) {
|
|
257
232
|
const str = holidayDescription[ev.getDesc()] || holidayDescription[ev.basename()] || '';
|
|
258
|
-
|
|
259
233
|
if (firstSentence && str) {
|
|
260
234
|
const dot = str.indexOf('.');
|
|
261
|
-
|
|
262
235
|
if (dot != -1) {
|
|
263
236
|
return str.substring(0, dot);
|
|
264
237
|
}
|
|
265
238
|
}
|
|
266
|
-
|
|
267
239
|
return str;
|
|
268
240
|
}
|
|
269
|
-
const HOLIDAY_IGNORE_MASK = core.flags.DAF_YOMI | core.flags.OMER_COUNT | core.flags.SHABBAT_MEVARCHIM | core.flags.MOLAD | core.flags.USER_EVENT | core.flags.HEBREW_DATE;
|
|
241
|
+
const HOLIDAY_IGNORE_MASK = core.flags.DAF_YOMI | core.flags.OMER_COUNT | core.flags.SHABBAT_MEVARCHIM | core.flags.MOLAD | core.flags.USER_EVENT | core.flags.HEBREW_DATE | core.flags.YERUSHALMI_YOMI;
|
|
242
|
+
|
|
270
243
|
/**
|
|
271
244
|
* Makes mulit-line text that summarizes Torah & Haftarah
|
|
272
245
|
* @param {Event} ev
|
|
273
246
|
* @param {boolean} il
|
|
274
247
|
* @return {string}
|
|
275
248
|
*/
|
|
276
|
-
|
|
277
249
|
function makeTorahMemoText(ev, il) {
|
|
278
250
|
const mask = ev.getFlags();
|
|
279
|
-
|
|
280
251
|
if (mask & HOLIDAY_IGNORE_MASK) {
|
|
281
252
|
return '';
|
|
253
|
+
} else if (typeof ev.eventTime !== 'undefined') {
|
|
254
|
+
return '';
|
|
282
255
|
}
|
|
283
|
-
|
|
284
256
|
const reading = mask & core.flags.PARSHA_HASHAVUA ? leyning.getLeyningForParshaHaShavua(ev, il) : leyning.getLeyningForHoliday(ev, il);
|
|
285
257
|
let memo = '';
|
|
286
|
-
|
|
287
258
|
if (reading && (reading.summary || reading.haftara)) {
|
|
288
259
|
if (reading.summary) {
|
|
289
260
|
memo += `Torah: ${reading.summary}`;
|
|
290
261
|
}
|
|
291
|
-
|
|
292
262
|
if (reading.summary && reading.haftara) {
|
|
293
263
|
memo += '\n';
|
|
294
264
|
}
|
|
295
|
-
|
|
296
265
|
if (reading.haftara) {
|
|
297
266
|
memo += 'Haftarah: ' + reading.haftara;
|
|
298
|
-
|
|
299
267
|
if (reading.reason && reading.reason.haftara) {
|
|
300
268
|
memo += ' | ' + reading.reason.haftara;
|
|
301
269
|
}
|
|
302
270
|
}
|
|
303
271
|
}
|
|
304
|
-
|
|
305
272
|
if (reading && reading.sephardic) {
|
|
306
273
|
memo += '\nHaftarah for Sephardim: ' + reading.sephardic;
|
|
307
274
|
}
|
|
308
|
-
|
|
309
275
|
return memo;
|
|
310
276
|
}
|
|
277
|
+
|
|
311
278
|
/**
|
|
312
279
|
* Appends utm_source and utm_medium parameters to a URL
|
|
313
280
|
* @param {string} url
|
|
@@ -317,24 +284,19 @@ function makeTorahMemoText(ev, il) {
|
|
|
317
284
|
* @param {string} utmCampaign
|
|
318
285
|
* @return {string}
|
|
319
286
|
*/
|
|
320
|
-
|
|
321
287
|
function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
|
|
322
288
|
const u = new URL(url);
|
|
323
289
|
const isHebcal = u.host === 'www.hebcal.com';
|
|
324
|
-
|
|
325
290
|
if (isHebcal) {
|
|
326
291
|
if (il) {
|
|
327
292
|
u.searchParams.set('i', 'on');
|
|
328
293
|
}
|
|
329
|
-
|
|
330
294
|
const path = u.pathname;
|
|
331
295
|
const isHolidays = path.startsWith('/holidays/');
|
|
332
296
|
const isSedrot = path.startsWith('/sedrot/');
|
|
333
297
|
const isOmer = path.startsWith('/omer/');
|
|
334
|
-
|
|
335
298
|
if (isHolidays || isSedrot || isOmer) {
|
|
336
299
|
u.host = 'hebcal.com';
|
|
337
|
-
|
|
338
300
|
if (isHolidays) {
|
|
339
301
|
u.pathname = '/h/' + path.substring(10);
|
|
340
302
|
} else if (isSedrot) {
|
|
@@ -343,51 +305,41 @@ function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
|
|
|
343
305
|
// isOmer
|
|
344
306
|
u.pathname = '/o/' + path.substring(6);
|
|
345
307
|
}
|
|
346
|
-
|
|
347
308
|
if (!utmCampaign || !(utmCampaign.startsWith('ical-') || utmCampaign.startsWith('pdf-'))) {
|
|
348
309
|
if (utmSource) {
|
|
349
310
|
u.searchParams.set('us', utmSource);
|
|
350
311
|
}
|
|
351
|
-
|
|
352
312
|
if (utmMedium) {
|
|
353
313
|
u.searchParams.set('um', utmMedium);
|
|
354
314
|
}
|
|
355
315
|
}
|
|
356
|
-
|
|
357
316
|
if (utmCampaign) {
|
|
358
317
|
u.searchParams.set('uc', utmCampaign);
|
|
359
318
|
}
|
|
360
|
-
|
|
361
319
|
return u.toString();
|
|
362
320
|
}
|
|
363
321
|
}
|
|
364
|
-
|
|
365
322
|
utmSource = isHebcal ? utmSource : 'hebcal.com';
|
|
366
|
-
|
|
367
323
|
if (utmSource) {
|
|
368
324
|
u.searchParams.set('utm_source', utmSource);
|
|
369
325
|
}
|
|
370
|
-
|
|
371
326
|
if (utmMedium) {
|
|
372
327
|
u.searchParams.set('utm_medium', utmMedium);
|
|
373
328
|
}
|
|
374
|
-
|
|
375
329
|
if (utmCampaign) {
|
|
376
330
|
u.searchParams.set('utm_campaign', utmCampaign);
|
|
377
331
|
}
|
|
378
|
-
|
|
379
332
|
return u.toString();
|
|
380
333
|
}
|
|
334
|
+
|
|
381
335
|
/**
|
|
382
336
|
* @private
|
|
383
337
|
* @param {Event} ev
|
|
384
338
|
* @return {boolean}
|
|
385
339
|
*/
|
|
386
|
-
|
|
387
340
|
function shouldRenderBrief(ev) {
|
|
388
341
|
if (typeof ev.eventTime !== 'undefined') return true;
|
|
389
342
|
const mask = ev.getFlags();
|
|
390
|
-
|
|
391
343
|
if (mask & core.flags.HEBREW_DATE) {
|
|
392
344
|
const hd = ev.getDate();
|
|
393
345
|
return hd.getDate() === 1 ? false : true;
|
|
@@ -402,6 +354,7 @@ function shouldRenderBrief(ev) {
|
|
|
402
354
|
}
|
|
403
355
|
}
|
|
404
356
|
|
|
357
|
+
// eslint-disable-next-line max-len
|
|
405
358
|
const csvHeader = '"Subject","Start Date","Start Time","End Date","End Time","All day event","Description","Show time as","Location"';
|
|
406
359
|
const CATEGORY = {
|
|
407
360
|
dafyomi: 'Daf Yomi',
|
|
@@ -414,13 +367,13 @@ const CATEGORY = {
|
|
|
414
367
|
roshchodesh: 'Jewish Holidays',
|
|
415
368
|
user: 'Personal'
|
|
416
369
|
};
|
|
370
|
+
|
|
417
371
|
/**
|
|
418
372
|
* Renders an Event as a string
|
|
419
373
|
* @param {Event} e
|
|
420
374
|
* @param {CalOptions} options
|
|
421
375
|
* @return {string}
|
|
422
376
|
*/
|
|
423
|
-
|
|
424
377
|
function eventToCsv(e, options) {
|
|
425
378
|
const d = e.getDate().greg();
|
|
426
379
|
const mday = d.getDate();
|
|
@@ -433,62 +386,51 @@ function eventToCsv(e, options) {
|
|
|
433
386
|
let allDay = '"true"';
|
|
434
387
|
const timed = Boolean(e.eventTime);
|
|
435
388
|
let subj = shouldRenderBrief(e) ? e.renderBrief(options.locale) : e.render(options.locale);
|
|
436
|
-
|
|
437
389
|
if (e.eventTime) {
|
|
438
390
|
const timeStr = core.HebrewCalendar.reformatTimeStr(e.eventTimeStr, ' PM', options);
|
|
439
391
|
endTime = startTime = `"${timeStr}"`;
|
|
440
392
|
endDate = date;
|
|
441
393
|
allDay = '"false"';
|
|
442
394
|
}
|
|
443
|
-
|
|
444
395
|
let loc = 'Jewish Holidays';
|
|
445
396
|
const mask = e.getFlags();
|
|
446
|
-
|
|
447
397
|
if (timed && options.location && options.location.name) {
|
|
448
398
|
const locationName = options.location.name;
|
|
449
399
|
const comma = locationName.indexOf(',');
|
|
450
400
|
loc = comma === -1 ? locationName : locationName.substring(0, comma);
|
|
451
401
|
} else if (mask & core.flags.DAF_YOMI) {
|
|
452
402
|
const colon = subj.indexOf(': ');
|
|
453
|
-
|
|
454
403
|
if (colon != -1) {
|
|
455
404
|
loc = subj.substring(0, colon);
|
|
456
405
|
subj = subj.substring(colon + 2);
|
|
457
406
|
}
|
|
458
407
|
} else {
|
|
459
408
|
const category = CATEGORY[getEventCategories(e)[0]];
|
|
460
|
-
|
|
461
409
|
if (category) {
|
|
462
410
|
loc = category;
|
|
463
411
|
}
|
|
464
412
|
}
|
|
465
|
-
|
|
466
413
|
subj = subj.replace(/,/g, '').replace(/"/g, '\'\'');
|
|
467
|
-
|
|
468
414
|
if (options.appendHebrewToSubject) {
|
|
469
415
|
const hebrew = e.renderBrief('he');
|
|
470
|
-
|
|
471
416
|
if (hebrew) {
|
|
472
417
|
subj += ` / ${hebrew}`;
|
|
473
418
|
}
|
|
474
419
|
}
|
|
475
|
-
|
|
476
420
|
let memo0 = e.memo || getHolidayDescription(e, true);
|
|
477
|
-
|
|
478
421
|
if (!memo0 && typeof e.linkedEvent !== 'undefined') {
|
|
479
422
|
memo0 = e.linkedEvent.render(options.locale);
|
|
480
423
|
}
|
|
481
|
-
|
|
482
424
|
const memo = memo0.replace(/,/g, ';').replace(/"/g, '\'\'').replace(/\n/g, ' / ');
|
|
483
425
|
const showTimeAs = timed || mask & core.flags.CHAG ? 4 : 3;
|
|
484
426
|
return `"${subj}",${date},${startTime},${endDate},${endTime},${allDay},"${memo}","${showTimeAs}","${loc}"`;
|
|
485
427
|
}
|
|
428
|
+
|
|
486
429
|
/**
|
|
487
430
|
* @param {Event[]} events
|
|
488
431
|
* @param {HebcalOptions} options
|
|
489
432
|
* @return {string}
|
|
490
433
|
*/
|
|
491
|
-
|
|
492
434
|
function eventsToCsv(events, options) {
|
|
493
435
|
return [csvHeader].concat(events.map(e => eventToCsv(e, options))).join('\r\n') + '\r\n';
|
|
494
436
|
}
|
|
@@ -498,10 +440,10 @@ function eventsToCsv(events, options) {
|
|
|
498
440
|
* @param {Event} ev
|
|
499
441
|
* @return {string}
|
|
500
442
|
*/
|
|
501
|
-
|
|
502
443
|
function eventIsoDate(ev) {
|
|
503
444
|
return toISOString(ev.getDate().greg());
|
|
504
445
|
}
|
|
446
|
+
|
|
505
447
|
/**
|
|
506
448
|
* Formats a list events for the classic Hebcal.com JSON API response
|
|
507
449
|
* @param {Event[]} events
|
|
@@ -509,25 +451,22 @@ function eventIsoDate(ev) {
|
|
|
509
451
|
* @param {boolean} [leyning=true]
|
|
510
452
|
* @return {Object}
|
|
511
453
|
*/
|
|
512
|
-
|
|
513
|
-
|
|
514
454
|
function eventsToClassicApi(events, options, leyning = true) {
|
|
515
455
|
const result = {
|
|
516
456
|
title: getCalendarTitle(events, options),
|
|
517
457
|
date: new Date().toISOString()
|
|
518
458
|
};
|
|
519
459
|
result.location = locationToPlainObj(options.location);
|
|
520
|
-
|
|
521
460
|
if (events.length) {
|
|
522
461
|
result.range = {
|
|
523
462
|
start: eventIsoDate(events[0]),
|
|
524
463
|
end: eventIsoDate(events[events.length - 1])
|
|
525
464
|
};
|
|
526
465
|
}
|
|
527
|
-
|
|
528
466
|
result.items = events.map(ev => eventToClassicApiObject(ev, options, leyning));
|
|
529
467
|
return result;
|
|
530
468
|
}
|
|
469
|
+
|
|
531
470
|
/**
|
|
532
471
|
* Converts a Hebcal event to a classic Hebcal.com JSON API object
|
|
533
472
|
* @param {Event} ev
|
|
@@ -535,7 +474,6 @@ function eventsToClassicApi(events, options, leyning = true) {
|
|
|
535
474
|
* @param {boolean} [leyning=true]
|
|
536
475
|
* @return {Object}
|
|
537
476
|
*/
|
|
538
|
-
|
|
539
477
|
function eventToClassicApiObject(ev, options, leyning$1 = true) {
|
|
540
478
|
const timed = Boolean(ev.eventTime);
|
|
541
479
|
const hd = ev.getDate();
|
|
@@ -547,63 +485,48 @@ function eventToClassicApiObject(ev, options, leyning$1 = true) {
|
|
|
547
485
|
let title = shouldRenderBrief(ev) ? ev.renderBrief(options.locale) : ev.render(options.locale);
|
|
548
486
|
const desc = ev.getDesc();
|
|
549
487
|
const candles = desc === 'Havdalah' || desc === 'Candle lighting';
|
|
550
|
-
|
|
551
488
|
if (candles) {
|
|
552
489
|
const time = core.HebrewCalendar.reformatTimeStr(ev.eventTimeStr, 'pm', options);
|
|
553
490
|
title += ': ' + time;
|
|
554
491
|
}
|
|
555
|
-
|
|
556
492
|
const result = {
|
|
557
493
|
title: title,
|
|
558
494
|
date: date
|
|
559
495
|
};
|
|
560
|
-
|
|
561
496
|
if (!timed) {
|
|
562
497
|
result.hdate = hd.toString();
|
|
563
498
|
}
|
|
564
|
-
|
|
565
499
|
result.category = categories[0];
|
|
566
|
-
|
|
567
500
|
if (categories.length > 1) {
|
|
568
501
|
result.subcat = categories[1];
|
|
569
502
|
}
|
|
570
|
-
|
|
571
503
|
if (categories[0] === 'holiday' && mask & core.flags.CHAG) {
|
|
572
504
|
result.yomtov = true;
|
|
573
505
|
}
|
|
574
|
-
|
|
575
506
|
if (title != desc) {
|
|
576
507
|
result.title_orig = desc;
|
|
577
508
|
}
|
|
578
|
-
|
|
579
509
|
const hebrew = ev.renderBrief('he');
|
|
580
|
-
|
|
581
510
|
if (hebrew) {
|
|
582
511
|
result.hebrew = core.Locale.hebrewStripNikkud(hebrew);
|
|
583
512
|
}
|
|
584
|
-
|
|
585
513
|
if (!candles) {
|
|
586
514
|
if (leyning$1) {
|
|
587
515
|
const il = options.il;
|
|
588
516
|
const isParsha = mask === core.flags.PARSHA_HASHAVUA;
|
|
589
517
|
const reading = isParsha ? leyning.getLeyningForParshaHaShavua(ev, il) : leyning.getLeyningForHoliday(ev, il);
|
|
590
|
-
|
|
591
518
|
if (reading) {
|
|
592
519
|
result.leyning = formatLeyningResult(reading);
|
|
593
520
|
const hyear = hd.getFullYear();
|
|
594
|
-
|
|
595
521
|
if (isParsha && !il && hyear >= 5745) {
|
|
596
522
|
const triReading = triennial.getTriennialForParshaHaShavua(ev);
|
|
597
|
-
|
|
598
523
|
if (triReading) {
|
|
599
524
|
result.leyning.triennial = formatAliyot({}, triReading.aliyot);
|
|
600
525
|
}
|
|
601
526
|
}
|
|
602
527
|
}
|
|
603
528
|
}
|
|
604
|
-
|
|
605
529
|
const url = ev.url();
|
|
606
|
-
|
|
607
530
|
if (url) {
|
|
608
531
|
const utmSource = options.utmSource || 'js';
|
|
609
532
|
const utmMedium = options.utmMedium || 'api';
|
|
@@ -611,7 +534,6 @@ function eventToClassicApiObject(ev, options, leyning$1 = true) {
|
|
|
611
534
|
result.link = appendIsraelAndTracking(url, options.il, utmSource, utmMedium, utmCampaign);
|
|
612
535
|
}
|
|
613
536
|
}
|
|
614
|
-
|
|
615
537
|
if (mask & core.flags.OMER_COUNT) {
|
|
616
538
|
result.omer = {
|
|
617
539
|
count: {
|
|
@@ -625,7 +547,6 @@ function eventToClassicApiObject(ev, options, leyning$1 = true) {
|
|
|
625
547
|
}
|
|
626
548
|
};
|
|
627
549
|
}
|
|
628
|
-
|
|
629
550
|
if (options.heDateParts && !timed || mask & core.flags.HEBREW_DATE) {
|
|
630
551
|
const yy = hd.getFullYear();
|
|
631
552
|
const mm = hd.getMonthName();
|
|
@@ -636,31 +557,26 @@ function eventToClassicApiObject(ev, options, leyning$1 = true) {
|
|
|
636
557
|
d: core.gematriya(dd)
|
|
637
558
|
};
|
|
638
559
|
}
|
|
639
|
-
|
|
640
560
|
const memo = ev.memo || holidayDescription[ev.basename()];
|
|
641
|
-
|
|
642
561
|
if (memo) {
|
|
643
562
|
result.memo = memo;
|
|
644
563
|
} else if (typeof ev.linkedEvent !== 'undefined') {
|
|
645
564
|
result.memo = ev.linkedEvent.render(options.locale);
|
|
646
565
|
}
|
|
647
|
-
|
|
648
566
|
if (options.includeEvent) {
|
|
649
567
|
result.ev = ev;
|
|
650
568
|
}
|
|
651
|
-
|
|
652
569
|
return result;
|
|
653
570
|
}
|
|
571
|
+
|
|
654
572
|
/**
|
|
655
573
|
* @param {Object} result
|
|
656
574
|
* @param {Object} aliyot
|
|
657
575
|
* @return {Object}
|
|
658
576
|
*/
|
|
659
|
-
|
|
660
577
|
function formatAliyot(result, aliyot) {
|
|
661
578
|
Object.keys(aliyot).forEach(num => {
|
|
662
579
|
const aliyah = aliyot[num];
|
|
663
|
-
|
|
664
580
|
if (typeof aliyah !== 'undefined') {
|
|
665
581
|
const k = num == 'M' ? 'maftir' : num;
|
|
666
582
|
result[k] = leyning.formatAliyahWithBook(aliyah);
|
|
@@ -668,31 +584,25 @@ function formatAliyot(result, aliyot) {
|
|
|
668
584
|
});
|
|
669
585
|
return result;
|
|
670
586
|
}
|
|
587
|
+
|
|
671
588
|
/**
|
|
672
589
|
* @param {Leyning} reading
|
|
673
590
|
* @return {Object}
|
|
674
591
|
*/
|
|
675
|
-
|
|
676
|
-
|
|
677
592
|
function formatLeyningResult(reading) {
|
|
678
593
|
const result = {};
|
|
679
|
-
|
|
680
594
|
if (reading.summary) {
|
|
681
595
|
result.torah = reading.summary;
|
|
682
596
|
}
|
|
683
|
-
|
|
684
597
|
if (reading.haftara) {
|
|
685
598
|
result.haftarah = reading.haftara;
|
|
686
599
|
}
|
|
687
|
-
|
|
688
600
|
if (reading.sephardic) {
|
|
689
601
|
result.haftarah_sephardic = reading.sephardic;
|
|
690
602
|
}
|
|
691
|
-
|
|
692
603
|
if (reading.fullkriyah) {
|
|
693
604
|
formatAliyot(result, reading.fullkriyah);
|
|
694
605
|
}
|
|
695
|
-
|
|
696
606
|
if (reading.reason) {
|
|
697
607
|
['7', '8', 'M'].forEach(num => {
|
|
698
608
|
if (reading.reason[num]) {
|
|
@@ -700,12 +610,10 @@ function formatLeyningResult(reading) {
|
|
|
700
610
|
result[k] += ' | ' + reading.reason[num];
|
|
701
611
|
}
|
|
702
612
|
});
|
|
703
|
-
|
|
704
613
|
if (reading.reason.haftara) {
|
|
705
614
|
result.haftarah += ' | ' + reading.reason.haftara;
|
|
706
615
|
}
|
|
707
616
|
}
|
|
708
|
-
|
|
709
617
|
return result;
|
|
710
618
|
}
|
|
711
619
|
|
|
@@ -719,7 +627,6 @@ function formatLeyningResult(reading) {
|
|
|
719
627
|
* @param {string} utmMedium
|
|
720
628
|
* @return {string[]}
|
|
721
629
|
*/
|
|
722
|
-
|
|
723
630
|
function getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium) {
|
|
724
631
|
let link;
|
|
725
632
|
let guid;
|
|
@@ -730,7 +637,6 @@ function getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium) {
|
|
|
730
637
|
const descAnchor = makeAnchor(ev.getDesc());
|
|
731
638
|
const anchor = `${dtAnchor}-${descAnchor}`;
|
|
732
639
|
const url0 = ev.url();
|
|
733
|
-
|
|
734
640
|
if (url0) {
|
|
735
641
|
link = appendIsraelAndTracking(url0, il, utmSource, utmMedium).replace(/&/g, '&');
|
|
736
642
|
guid = `${url0}#${anchor}`;
|
|
@@ -740,10 +646,8 @@ function getLinkAndGuid(ev, il, tzid, mainUrl, utmSource, utmMedium) {
|
|
|
740
646
|
guid = url1.replace(/&/g, '&') + `#${anchor}`;
|
|
741
647
|
link = `${url}#${anchor}`;
|
|
742
648
|
}
|
|
743
|
-
|
|
744
649
|
return [link, guid];
|
|
745
650
|
}
|
|
746
|
-
|
|
747
651
|
const localeToLg = {
|
|
748
652
|
's': 'en',
|
|
749
653
|
'a': 'en',
|
|
@@ -752,12 +656,12 @@ const localeToLg = {
|
|
|
752
656
|
'ah': 'en',
|
|
753
657
|
'sh': 'en'
|
|
754
658
|
};
|
|
659
|
+
|
|
755
660
|
/**
|
|
756
661
|
* @param {Event[]} events
|
|
757
662
|
* @param {CalOptions} options
|
|
758
663
|
* @return {string}
|
|
759
664
|
*/
|
|
760
|
-
|
|
761
665
|
function eventsToRss2(events, options) {
|
|
762
666
|
options.dayFormat = new Intl.DateTimeFormat('en-US', {
|
|
763
667
|
weekday: 'long',
|
|
@@ -794,6 +698,7 @@ function eventsToRss2(events, options) {
|
|
|
794
698
|
str += '</channel>\n</rss>\n';
|
|
795
699
|
return str;
|
|
796
700
|
}
|
|
701
|
+
|
|
797
702
|
/**
|
|
798
703
|
* @private
|
|
799
704
|
* @param {Event} ev
|
|
@@ -802,27 +707,22 @@ function eventsToRss2(events, options) {
|
|
|
802
707
|
* @param {string} lastBuildDate
|
|
803
708
|
* @return {string}
|
|
804
709
|
*/
|
|
805
|
-
|
|
806
710
|
function getPubDate(ev, evPubDate, evDate, lastBuildDate) {
|
|
807
711
|
if (evPubDate) {
|
|
808
712
|
const dt = ev.eventTime;
|
|
809
|
-
|
|
810
713
|
if (dt) {
|
|
811
714
|
return dt.toUTCString();
|
|
812
715
|
}
|
|
813
|
-
|
|
814
716
|
return evDate.toUTCString().replace(/ \S+ GMT$/, ' 00:00:00 GMT');
|
|
815
717
|
}
|
|
816
|
-
|
|
817
718
|
return lastBuildDate;
|
|
818
719
|
}
|
|
720
|
+
|
|
819
721
|
/**
|
|
820
722
|
* @param {Event} ev
|
|
821
723
|
* @param {CalOptions} options
|
|
822
724
|
* @return {string}
|
|
823
725
|
*/
|
|
824
|
-
|
|
825
|
-
|
|
826
726
|
function eventToRssItem2(ev, options) {
|
|
827
727
|
let subj = ev.render();
|
|
828
728
|
const evDate = ev.getDate().greg();
|
|
@@ -840,10 +740,8 @@ function eventToRssItem2(ev, options) {
|
|
|
840
740
|
const desc = ev.getDesc();
|
|
841
741
|
const candles = desc === 'Havdalah' || desc === 'Candle lighting';
|
|
842
742
|
let memo;
|
|
843
|
-
|
|
844
743
|
if (candles) {
|
|
845
744
|
const colon = subj.indexOf(': ');
|
|
846
|
-
|
|
847
745
|
if (colon != -1) {
|
|
848
746
|
const options = {
|
|
849
747
|
location,
|
|
@@ -856,7 +754,6 @@ function eventToRssItem2(ev, options) {
|
|
|
856
754
|
} else {
|
|
857
755
|
memo = ev.getFlags() & core.flags.PARSHA_HASHAVUA ? makeTorahMemoText(ev, il) : ev.memo || holidayDescription[ev.basename()];
|
|
858
756
|
}
|
|
859
|
-
|
|
860
757
|
const dayFormat = options.dayFormat;
|
|
861
758
|
const description = memo || dayFormat.format(evDate);
|
|
862
759
|
const geoTags = cat0 == 'candles' ? `<geo:lat>${location.getLatitude()}</geo:lat>\n<geo:long>${location.getLongitude()}</geo:long>\n` : '';
|
|
@@ -878,15 +775,12 @@ ${geoTags}</item>
|
|
|
878
775
|
* @param {boolean} il true if Israel
|
|
879
776
|
* @return {Object}
|
|
880
777
|
*/
|
|
881
|
-
|
|
882
778
|
function eventToFullCalendar(ev, tzid, il) {
|
|
883
779
|
const classes = getEventCategories(ev);
|
|
884
780
|
const mask = ev.getFlags();
|
|
885
|
-
|
|
886
781
|
if (classes[0] == 'holiday' && mask & core.flags.CHAG) {
|
|
887
782
|
classes.push('yomtov');
|
|
888
783
|
}
|
|
889
|
-
|
|
890
784
|
const timed = Boolean(ev.eventTime);
|
|
891
785
|
const title = shouldRenderBrief(ev) ? ev.renderBrief() : ev.render();
|
|
892
786
|
const start = timed ? core.Zmanim.formatISOWithTimeZone(tzid, ev.eventTime) : toISOString(ev.getDate().greg());
|
|
@@ -897,30 +791,23 @@ function eventToFullCalendar(ev, tzid, il) {
|
|
|
897
791
|
className: classes.join(' ')
|
|
898
792
|
};
|
|
899
793
|
const hebrew = ev.renderBrief('he');
|
|
900
|
-
|
|
901
794
|
if (hebrew) {
|
|
902
795
|
result.hebrew = core.Locale.hebrewStripNikkud(hebrew);
|
|
903
796
|
}
|
|
904
|
-
|
|
905
797
|
const url = ev.url();
|
|
906
|
-
|
|
907
798
|
if (url) {
|
|
908
799
|
result.url = appendIsraelAndTracking(url, il, 'js', 'fc');
|
|
909
800
|
}
|
|
910
|
-
|
|
911
801
|
const desc = ev.getDesc();
|
|
912
802
|
const candles = desc === 'Havdalah' || desc === 'Candle lighting';
|
|
913
|
-
|
|
914
803
|
if (!candles) {
|
|
915
804
|
const memo = mask & core.flags.PARSHA_HASHAVUA ? makeTorahMemoText(ev, il) : ev.memo || holidayDescription[ev.basename()];
|
|
916
|
-
|
|
917
805
|
if (memo) {
|
|
918
806
|
result.description = memo;
|
|
919
807
|
} else if (typeof ev.linkedEvent !== 'undefined') {
|
|
920
808
|
result.description = ev.linkedEvent.render();
|
|
921
809
|
}
|
|
922
810
|
}
|
|
923
|
-
|
|
924
811
|
return result;
|
|
925
812
|
}
|
|
926
813
|
|