Files
psu-schedule/shared/places.js
Zakhar Timoshenko 297091cb0e feat: Add Settings and Subjects screens with theme reveal functionality
- Implemented SettingsScreen for user preferences including theme selection, reminders, and notifications.
- Created SubjectsScreen to display subjects with upcoming lessons and associated details.
- Introduced ThemeReveal for a smooth transition between light and dark themes.
- Added support for managing notes and tasks related to subjects.
- Enhanced UI components for better user experience and accessibility.
2026-10-24 02:47:37 +03:00

41 lines
1.8 KiB
JavaScript

// "Занятия в Полоцке": Word marks the days a group spends in another town over the day's first
// row; the parser keeps them as notes of the day (server/places.js). The notes of a day for one
// group, shared by the server's timetable and the browser.
/**
* The notes on a weekday (or a date) of the group: `{place, text, subgroup}`, the subgroup null
* for the whole group. The same note in every subgroup (`labels`) is the whole group's.
*/
export function placesOn(places, group, labels, day, date = null) {
const on = (places || [])
.filter((p) => p.groups.includes(group) && p.day === day && (!p.date || p.date === date))
.map((p) => ({
place: p.place,
text: p.text,
subgroup: p.subgroups.find((s) => s.group === group)?.label || null,
// "13:40": the note holds from that lesson on, not the whole day.
...(p.from && { from: p.from }),
}));
const whole = on.filter((p) => !p.subgroup);
for (const p of on)
if (
p.subgroup &&
!whole.some((w) => w.text === p.text) &&
labels.length &&
labels.every((label) => on.some((o) => o.subgroup === label && o.text === p.text))
)
whole.push({ ...p, subgroup: null });
const parts = on.filter((p) => p.subgroup && !whole.some((w) => w.text === p.text));
return [...whole, ...parts].filter(
(p, i, all) => all.findIndex((o) => o.text === p.text && o.subgroup === p.subgroup) === i,
);
}
/** The notes for the student's subgroup; a note for their own subgroup reads as the whole day's. */
export function placesFor(list, subgroup) {
return list
.filter((p) => !subgroup || !p.subgroup || p.subgroup === subgroup)
.map((p) => (subgroup ? { ...p, subgroup: null } : p))
.filter((p, i, all) => all.findIndex((o) => o.text === p.text && o.subgroup === p.subgroup) === i);
}