Skip to content

Commit

Permalink
Misc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
NightScript370 committed Dec 25, 2024
1 parent 77b9e51 commit 4cb499e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 15 deletions.
33 changes: 24 additions & 9 deletions assets/js/features/print-web-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,14 +759,15 @@ function messageHandler (x) {
"en-et": "Tekufath " + tekufaMonth.en
}[x.data.lang]));

let tekufaDate;
/* switch (x.data.lang) {
default: */
tekufaDate = `${daysForLocale('en')[initTekuf.dayOfWeek]}, ${monthForLocale('en')[initTekuf.month]} ${getOrdinal(initTekuf.day, true)}`;
//}
const tekufaDate = formatDate(initTekuf);
const tekufaTimingDiv = document.createElement("p");
tekufaTimingDiv.innerHTML = tekufaDate;
tekufaTimingDiv.appendChild(document.createElement("br"));

if (nextTekufaJDate.getJewishMonth() == KosherZmanim.JewishDate.TISHREI && !x.data.israel) {
tekufaTitle.innerHTML += " - " + tekufaDate;
} else {
tekufaTimingDiv.innerHTML = tekufaDate;
tekufaTimingDiv.appendChild(document.createElement("br"));
}
tekufaTimingDiv.appendChild(document.createTextNode({
"hb": "אל תשתה מים בין ",
"en": "Refrain from water between ",
Expand All @@ -776,14 +777,23 @@ function messageHandler (x) {
initTekuf.round("minute").add({ minutes: 30 }).toLocaleString(...defaulTF),
].join('-')));

if (nextTekufaJDate.getJewishMonth() == KosherZmanim.JewishDate.TISHREI && !x.data.israel) {
tekufaTimingDiv.appendChild(document.createElement("br"));
tekufaTimingDiv.appendChild(document.createTextNode({
"en": "Switch to ברך עלינו on ",
"hb": "תחליף לברך עלינו ביום ",
"en-et": "Switch to ברך עלינו on "
}[x.data.lang] + formatDate(initTekuf.add({ days: 60 }))))
}

tekufaContainer.appendChild(tekufaTitle);
tekufaContainer.appendChild(tekufaTimingDiv);
thisMonthFooter.lastElementChild.appendChild(tekufaContainer);
}
}

if (hamesDate && thisMonthFooter.lastElementChild.hasAttribute('data-zyfooter-hametz')) {
const hamesName = `${daysForLocale('en')[hamesDate.dayOfWeek]}, ${monthForLocale('en')[hamesDate.month]} ${getOrdinal(hamesDate.day, true)}`;
const hamesName = formatDate(hamesDate);
const hametzContainer = document.createElement("div");
const hametzTitle = document.createElement("h5");
hametzTitle.innerHTML = {
Expand Down Expand Up @@ -870,4 +880,9 @@ function rangeTimes(start, middle, end, inclusive=true) {
acceptedValues.push(0);

return acceptedValues.includes(Temporal.ZonedDateTime.compare(middle, start)) && acceptedValues.includes(Temporal.ZonedDateTime.compare(end, middle))
};
};

/** @param {Temporal.ZonedDateTime|Temporal.PlainDate} date */
function formatDate(date) {
return `${daysForLocale('en')[date.dayOfWeek]}, ${monthForLocale('en')[date.month]} ${getOrdinal(date.day, true)}`
}
23 changes: 18 additions & 5 deletions assets/js/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,19 @@ const elements = {
}

/** @param {geoNamesResponse["postalcodes"][0] | geoNamesResponse["geonames"][0]} geoName */
const geoNameTitleGenerator = (geoName) => [...new Set([('name' in geoName ? geoName.name : geoName.placeName),
geoName.adminName1.toLowerCase() || geoName.adminCode1.toLowerCase(),
('countryName' in geoName ? geoName.countryName.toLowerCase() : geoName.countryCode.toLowerCase())])].filter(Boolean).join(", ");
const geoNameTitleGenerator = (geoName) =>
[...new Set([
('name' in geoName ? geoName.name : geoName.placeName),
geoName.adminName1 || geoName.adminCode1,
('countryName' in geoName ? geoName.countryName : geoName.countryCode)
])]
.filter(Boolean)
.map(field => field
.split(" ")
.map(word => word[0] ? (word[0].toUpperCase() + word.substring(1).toLowerCase()) : word)
.join(" ")
)
.join(", ");

let pool;
const delay = (/** @type {Number} */ms) => new Promise(res => setTimeout(res, ms));
Expand All @@ -118,8 +128,9 @@ async function updateList(event) {

const q = elements.searchBar.value
.split(" ")
.map(word => word[0].toUpperCase() + word.substring(1).toLowerCase())
.map(word => word[0] ? (word[0].toUpperCase() + word.substring(1).toLowerCase()) : word)
.join(" ");
elements.searchBar.value = q;

if (q.length < 3) {
if ((event instanceof KeyboardEvent && event.key == "Enter") || event instanceof MouseEvent) {
Expand Down Expand Up @@ -273,7 +284,9 @@ async function updateList(event) {
openCalendarWithLocationInfo();
} else {
const list = document.getElementById("locationNames");
list.querySelectorAll('*').forEach(n => n.remove());
while (list.firstElementChild)
list.firstElementChild.remove()

for (const geoName of (locationName ? data.geonames : data.postalcodes)) {
const option = document.createElement("option");
option.setAttribute("value", geoNameTitleGenerator(geoName))
Expand Down
5 changes: 4 additions & 1 deletion assets/js/zmanimListUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,10 @@ class zmanimListUpdater {
let shemaKolenu = this.geoLocation.getLatitude() < 0;
if (settings.calendarToggle.tekufaCalc() == 'adabaravah') {
const talUmatarRAda = this.zmanFuncs.tekufaCalc.calculateTekufotRAda()[0].toPlainDate().add({ days: 60 })
shemaKolenu = shemaKolenu || KosherZmanim.Temporal.PlainDate.compare(talUmatarRAda, this.jCal.getDate()) == -1
shemaKolenu = shemaKolenu
|| (
KosherZmanim.Temporal.PlainDate.compare(talUmatarRAda, this.jCal.getDate()) == -1
&& calForRules.getDate().withCalendar('hebrew').month < 7)
}

/** @type {HTMLUListElement} */
Expand Down

0 comments on commit 4cb499e

Please sign in to comment.