From 0712b993ebf191166017b2d9e5dca4e21ccdbe58 Mon Sep 17 00:00:00 2001 From: "Michael J. Radwin" Date: Sun, 4 Aug 2024 08:32:18 -0700 Subject: [PATCH] Correctly display verses on Salkin JPS Study Bible for doubled parshiyot --- src/parshaCommon.js | 9 ++++++++- src/sedrot.js | 20 ++++++++++++++++++-- views/parsha-detail.ejs | 4 ++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/parshaCommon.js b/src/parshaCommon.js index 33356263..71fe2c31 100644 --- a/src/parshaCommon.js +++ b/src/parshaCommon.js @@ -150,7 +150,7 @@ export function lookupParshaMeta(parshaName) { name: parshaName, bookName: torahBookNames[parsha0.book - 1], anchor: makeAnchor(parshaName), - verses: parsha0.fullkriyah['1'][0] + '-' + parsha0.fullkriyah['7'][1], + verses: parshaVerses(parsha0), ...parsha0, }; if (parsha.combined) { @@ -164,6 +164,8 @@ export function lookupParshaMeta(parshaName) { parsha.p2anchor = makeAnchor(p2); const haftKey = p1 === 'Nitzavim' ? p1 : p2; parsha.haft = lookupParsha(haftKey).haft; + const p1meta = lookupParsha(p1); + parsha.p1verses = parshaVerses(p1meta); } else { parsha.ordinal = Locale.ordinal(parsha.num, 'en'); } @@ -178,6 +180,11 @@ export function lookupParshaMeta(parshaName) { return parsha; } +function parshaVerses(parshaMeta) { + const fk = parshaMeta.fullkriyah; + return fk['1'][0] + '-' + fk['7'][1]; +} + /** * @param {any} parsha * @return {any} diff --git a/src/sedrot.js b/src/sedrot.js index 03bf9cc5..316c67b9 100644 --- a/src/sedrot.js +++ b/src/sedrot.js @@ -341,9 +341,25 @@ function doIsraelDiasporaDiffer(parsha, il, hd, triennial) { return [false, '', '']; } +/** @return {number} */ +function nextParshaNum(parsha) { + if (parsha.num === 54) { + return 0; + } + return parsha.combined ? parshaNum.get(parsha.p2) : parsha.num; +} + +/** @return {number} */ +function prevParshaNum(parsha) { + if (parsha.num === 1) { + return 53; + } + return parsha.combined ? parshaNum.get(parsha.p1) - 2 : parsha.num - 2; +} + function makePrevNext(parsha, date, hd, il) { - const prevNum = parsha.num === 1 ? 53 : parsha.combined ? parshaNum.get(parsha.p1) - 2 : parsha.num - 2; - const nextNum = parsha.num === 54 ? 0 : parsha.combined ? parshaNum.get(parsha.p2) : parsha.num; + const prevNum = prevParshaNum(parsha); + const nextNum = nextParshaNum(parsha); const prevName = parshiot54[prevNum]; const nextName = parshiot54[nextNum]; if (date) { diff --git a/views/parsha-detail.ejs b/views/parsha-detail.ejs index 69b3c217..d1f9fa8f 100644 --- a/views/parsha-detail.ejs +++ b/views/parsha-detail.ejs @@ -207,7 +207,7 @@ Some congregations read the entire parsha every year (“Option A”). <% if (commentary['asin']) { - const altText = parsha.p1||parshaName + ': The JPS B’nai Mitzvah Torah Commentary (JPS Study Bible)'; + const altText = (parsha.p1||parshaName) + ': The JPS B’nai Mitzvah Torah Commentary (JPS Study Bible)'; %>