moved to API

This commit is contained in:
2026-03-08 22:24:34 -07:00
parent cf6b2611aa
commit 2caf566bf6
94 changed files with 1257 additions and 40930 deletions

View File

@@ -1,4 +1,5 @@
(function () {
const dataService = window.TarotDataService || {};
const {
DAY_IN_MS,
toTitleCase,
@@ -11,83 +12,24 @@
const BACKFILL_DAYS = 4;
const FORECAST_DAYS = 7;
function buildWeekEvents(geo, referenceData, anchorDate) {
const baseDate = anchorDate || new Date();
const events = [];
let runningId = 1;
for (let offset = -BACKFILL_DAYS; offset <= FORECAST_DAYS; offset += 1) {
const date = new Date(baseDate.getTime() + offset * DAY_IN_MS);
const hours = calcPlanetaryHoursForDayAndLocation(date, geo);
const moonIllum = window.SunCalc.getMoonIllumination(date);
const moonPhase = getMoonPhaseName(moonIllum.phase);
const sunInfo = getDecanForDate(date, referenceData.signs, referenceData.decansBySign);
const moonTarot = referenceData.planets.luna?.tarot?.majorArcana || "The High Priestess";
events.push({
id: `moon-${offset}`,
calendarId: "astrology",
category: "allday",
title: `Moon: ${moonPhase} (${Math.round(moonIllum.fraction * 100)}%) · ${moonTarot}`,
start: new Date(date.getFullYear(), date.getMonth(), date.getDate()),
end: new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59),
isReadOnly: true
});
if (sunInfo?.sign) {
const rulerPlanet = referenceData.planets[sunInfo.sign.rulingPlanetId];
const bodyParts = [
`${sunInfo.sign.symbol} ${toTitleCase(sunInfo.sign.element)} ${toTitleCase(sunInfo.sign.modality)}`,
rulerPlanet ? `Sign ruler: ${rulerPlanet.symbol} ${rulerPlanet.name}` : `Sign ruler: ${sunInfo.sign.rulingPlanetId}`
];
if (sunInfo.decan) {
const decanRuler = referenceData.planets[sunInfo.decan.rulerPlanetId];
const decanText = decanRuler
? `Decan ${sunInfo.decan.index}: ${sunInfo.decan.tarotMinorArcana} (${decanRuler.symbol} ${decanRuler.name})`
: `Decan ${sunInfo.decan.index}: ${sunInfo.decan.tarotMinorArcana}`;
bodyParts.unshift(decanText);
}
events.push({
id: `sun-${offset}`,
calendarId: "astrology",
category: "allday",
title: `Sun in ${sunInfo.sign.name} · ${sunInfo.sign.tarot.majorArcana}`,
body: bodyParts.join("\n"),
start: new Date(date.getFullYear(), date.getMonth(), date.getDate()),
end: new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59),
isReadOnly: true
});
}
for (const hour of hours) {
const planet = referenceData.planets[hour.planetId];
if (!planet) continue;
const calendarId = PLANET_CALENDAR_IDS.has(hour.planetId)
? `planet-${hour.planetId}`
: "planetary";
events.push({
id: `ph-${runningId++}`,
calendarId,
category: "time",
title: `${planet.symbol} ${planet.name} · ${planet.tarot.majorArcana}`,
body: `${planet.weekday} current · ${hour.isDaylight ? "Day" : "Night"} hour\n${planet.magickTypes}`,
raw: {
planetSymbol: planet.symbol,
planetName: planet.name,
tarotName: planet.tarot.majorArcana
},
start: hour.start,
end: hour.end,
isReadOnly: true
});
}
function normalizeApiEvent(event) {
if (!event || typeof event !== "object") {
return event;
}
return events;
return {
...event,
start: event.start ? new Date(event.start) : event.start,
end: event.end ? new Date(event.end) : event.end
};
}
async function buildWeekEvents(geo, referenceData, anchorDate) {
const payload = await dataService.fetchWeekEvents?.(geo, anchorDate);
const events = Array.isArray(payload?.events)
? payload.events
: (Array.isArray(payload) ? payload : []);
return events.map((event) => normalizeApiEvent(event));
}
window.TarotEventBuilder = {