Skip to content

Commit

Permalink
Joey Zaghi request: Select individual Zemanim for the excel/ics export
Browse files Browse the repository at this point in the history
  • Loading branch information
NightScript370 committed Dec 26, 2024
1 parent 4b135df commit a864c25
Show file tree
Hide file tree
Showing 7 changed files with 379 additions and 293 deletions.
64 changes: 64 additions & 0 deletions _includes/modals/export.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<div class="modal fade" id="exportModal" tabindex="-1" aria-labelledby="exportModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exportModalLabel">Export Field</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="export-zmanim-tab" data-bs-toggle="tab" data-bs-target="#export-zmanim-tab-pane" type="button" role="tab" aria-controls="export-zmanim-tab-pane" aria-selected="true">Zemanim Selection</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="export-holidays-tab" data-bs-toggle="tab" data-bs-target="#export-holidays-tab-pane" type="button" role="tab" aria-controls="export-holidays-tab-pane" aria-selected="false">Holiday Selection (ICS only)</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="export-zmanim-tab-pane" role="tabpanel" aria-labelledby="export-zmanim-tab" tabindex="0">
{% for item in site.data.zmanim %}
{% if item.shitot %}
{% for indZman in item.shitot %}
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="exportzmanid-{{ item.id }}-{{ indZman.id }}" checked>
<label class="form-check-label" for="exportzmanid-{{ item.id }}-{{ indZman.id }}">
<span class="lang lang-hb">{{ item.names.hb }} - {{ indZman.names.hb }}</span>
<span class="lang lang-et">{{ item.names.et }} - {{ indZman.names.et }}</span>
<span class="lang lang-en">{{ item.names.en }} - {{ indZman.names.en }}</span>
</label>
</div>
{% endfor %}
{% else %}
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="exportzmanid-{{ item.id }}" checked>
<label class="form-check-label" for="exportzmanid-{{ item.id }}">
<span class="lang lang-hb">{{ item.names.hb }}</span>
<span class="lang lang-et">{{ item.names.et }}</span>
<span class="lang lang-en">{{ item.names.en }}</span>
</label>
</div>
{% endif %}
{% endfor %}
</div>
<div class="tab-pane fade" id="export-holidays-tab-pane" role="tabpanel" aria-labelledby="export-holidays-tab" tabindex="0">
Coming soon! For now, every holiday (except Purim) is already included!
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="downloadModalBtn">
<i class="bi bi-calendar2-week"></i>
<span class="lang lang-en">Format as Digital Calendar</span>
<span class="lang lang-et">Format as Digital Calendar</span>
<span class="lang lang-hb">הורד לוח שנה דיגיטלי</span>
</button>
<button type="button" class="btn btn-primary" id="spreadSheetBtn">
<img src="/assets/images/download_spread.svg" alt="Download Spreadsheet" style="height: 1em;">
<span class="lang lang-en">Format as spreadsheet</span>
<span class="lang lang-et">Format as spreadsheet</span>
<span class="lang lang-hb">Format as spreadsheet</span>
</button>
</div>
</div>
</div>
</div>
6 changes: 4 additions & 2 deletions assets/js/WebsiteCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import * as KosherZmanim from "../libraries/kosherZmanim/kosher-zmanim.esm.js"
import { he as n2heWords, he_rt as n2ruWords } from "../libraries/n2words.esm.js";
import { AmudehHoraahZmanim, OhrHachaimZmanim } from "./ROYZmanim.js";

/** @typedef {{ hb: string, en: string, "en-et": string; "ru"?: string; }} langType */
/** @typedef {{display: -2|-1|0|1, code: string[], luxonObj: KosherZmanim.Temporal.ZonedDateTime, title: langType, merge_title: langType; function: string}} zmanData */

export default
class WebsiteCalendar extends KosherZmanim.JewishCalendar {
formatJewishFullDate() {
Expand Down Expand Up @@ -111,8 +114,7 @@ class WebsiteCalendar extends KosherZmanim.JewishCalendar {
* @param {{ hourCalculator: "degrees" | "seasonal"; tzeithIssurMelakha: { minutes: number; degree: number;}; tzeitTaanitHumra: boolean; }} funcSettings
*/
getZmanimInfo(independent, zmanCalc, zmanList, funcSettings) {
/** @typedef {{ hb: string, en: string, "en-et": string; "ru"?: string; }} langType */
/** @type {Record<string, {display: -2|-1|0|1, code: string[], luxonObj: KosherZmanim.Temporal.ZonedDateTime, title: langType, merge_title: langType; function: string}>} */
/** @type {Record<string, zmanData>} */
const calculatedZmanim = {}

for (const [zmanId, zmanInfo] of Object.entries(zmanList)) {
Expand Down
18 changes: 10 additions & 8 deletions assets/js/features/excelPrepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { AmudehHoraahZmanim, OhrHachaimZmanim } from "../ROYZmanim.js";
import { Temporal, GeoLocation } from "../../libraries/kosherZmanim/kosher-zmanim.esm.js";
import WebsiteCalendar from "../WebsiteCalendar.js";

/** @typedef {T[keyof T]} ValueOf<T> */

/**
* @param {boolean} amudehHoraahZman
* @param {[number, number, number, string | Temporal.CalendarProtocol]} plainDateParams
* @param {[string, number, number, number, string]} geoLocationData
* @param {boolean} useElevation
* @param {boolean} isIsrael
* @param {{ [s: string]: { function: string|null; yomTovInclusive: string|null; luachInclusive: "degrees"|"seasonal"|null; condition: string|null; title: { "en-et": string; en: string; hb: string; }}; }} zmanList
* @param {Parameters<import("../WebsiteCalendar.js").default["getZmanimInfo"]>[2]} zmanList
* @param {boolean} monthView
* @param {{ language: "en-et" | "en" | "he"; timeFormat: "h11" | "h12" | "h23" | "h24"; seconds: boolean; zmanInfoSettings: Parameters<typeof jCal.getZmanimInfo>[3]; calcConfig: Parameters<OhrHachaimZmanim["configSettings"]>; netzTimes: number[] }} funcSettings
*/
Expand Down Expand Up @@ -38,22 +40,22 @@ export default function spreadSheetExport (amudehHoraahZman, plainDateParams, ge
if (vNetz)
seeSun = vNetz.find(zDT => Math.abs(regularNetz.until(zDT).total('minutes')) <= 6)

// @ts-ignore
/** @param {import("../WebsiteCalendar.js").zmanData} entry */
function formatTime(entry) {
// @ts-ignore
const time = (entry.function == 'getNetz' && seeSun ? seeSun : entry.luxonObj)
return '=TIME(' + [time.hour, time.minute, time.second].join(', ') + ')'
}

const dailyZmanim = Object.values(jCal.getZmanimInfo(true, calc, zmanList, funcSettings.zmanInfoSettings))
.filter(entry => entry.display == 1)
const dailyZmanim = Object.entries(jCal.getZmanimInfo(true, calc, zmanList, funcSettings.zmanInfoSettings))
.filter(entry => entry[1].display == 1)
.map(entry => [
entry.function || (entry.title["en"].startsWith("Candle Lighting") ? "getCandleLighting" : ""),
{t: "d", v: new Date(entry.luxonObj.epochMilliseconds),
f: formatTime(entry), z:
entry[0],
{t: "d", v: new Date(entry[1].luxonObj.epochMilliseconds),
f: formatTime(entry[1]), z:
"h" + (["h23", "h24"].includes(funcSettings.timeFormat) ? "h" : "")
// @ts-ignore
+ ":mm" + (funcSettings.seconds || (entry.function == "getNetz" && seeSun) ? ":ss" : "")
+ ":mm" + (funcSettings.seconds || (entry[1].function == "getNetz" && seeSun) ? ":ss" : "")
+ (["h11", "h12"].includes(funcSettings.timeFormat) ? " AM/PM" : "")}
])

Expand Down
Loading

0 comments on commit a864c25

Please sign in to comment.