Loading portal/static/css/main.css +14 −14 Original line number Diff line number Diff line Loading @@ -263,26 +263,26 @@ a.detail:hover { color: white; } /* ------------------------ Agenda ------------------------ */ /* ------------------------ Fancy boxes (agenda, lunch menu) ------------------------ */ .agenda { .fancy.box { margin: 0 auto; } .agenda > * { .fancy.box > * { padding: 1em; } .agenda h2 { .fancy.box h2 { margin-top: 0; } .agenda ol { .fancy.box ol { padding-left: 1.5em; margin: 0; } .agenda .edit { .fancy.box .action { display: grid; grid-template-columns: max-content max-content; text-decoration: none; Loading @@ -292,20 +292,20 @@ a.detail:hover { column-gap: 0.5em; } .agenda .edit > i { .fancy.box .action > i { font-size: 150%; } .agenda { .fancy.box { background: none; height: max-content; } .agenda:has(.edit:active) { .fancy.box:has(.action:active) { box-shadow: none; } .agenda .content { .fancy.box .content { background: radial-gradient( circle, rgb(255, 255, 255) 0%, Loading @@ -316,23 +316,23 @@ a.detail:hover { z-index: 2; } .agenda .content:has(+ .edit:active) { .fancy.box .content:has(+ .action:active) { box-shadow: var(--shadow-width) var(--shadow-width) 5px rgba(0, 0, 0, 0.5); } .agenda .edit { .fancy.box .action { background: rgba(255, 255, 255, 0.9); border-bottom-right-radius: 1em; border-bottom-left-radius: 1em; } .agenda .edit { .fancy.box .action { position: relative; top: 0; left: 0; } .agenda .edit:active { .fancy.box .action:active { box-shadow: none; left: 2px; top: 2px; Loading portal/static/js/components/pages/UniServices.mjs +39 −14 Original line number Diff line number Diff line import { Service } from "../../model/Service.mjs" import { LunchMenu } from "../pieces/LunchMenu.mjs" import { ServiceLink } from "../pieces/ServiceLink.mjs" import { Base } from "./Base.mjs" Loading @@ -8,23 +9,55 @@ const germanDateFormatter = new Intl.DateTimeFormat("de-DE", { year: "numeric", }) /** * @returns the date the next lunch will likely be one (today, unless it is already afternoon, then tomorrow) */ function getNextLunchDate() { const nextLunchDate = new Date() if (nextLunchDate.getHours() >= 15) { // If it is 15:00 or later, next lunch will be tomorrow nextLunchDate.setDate(nextLunchDate.getDate() + 1) } return nextLunchDate } function getMensaLink() { const dayToShow = new Date() if (dayToShow.getHours() >= 15) { // If it is 15:00 or later, show tomorrow's menu dayToShow.setDate(dayToShow.getDate() + 1) return `https://www.stw.uni-heidelberg.de/external-tools/speiseplan/speiseplan.php?lang=de&mode=Mensa+Im+Neuenheimer+Feld+304&date=${germanDateFormatter.format(getNextLunchDate())}` } return `https://www.stw.uni-heidelberg.de/external-tools/speiseplan/speiseplan.php?lang=de&mode=Mensa+Im+Neuenheimer+Feld+304&date=${germanDateFormatter.format(dayToShow)}` const lunchMenu = { all: null, message: "Wird geladen...", async fetch() { try { this.all = await m.request({ method: "GET", url: `https://openmensa.org/api/v2/canteens/279/days/${getNextLunchDate().toISOString().split("T")[0]}/meals`, }) } catch (e) { this.message = "Das Menü konnte nicht geladen werden." } }, } export const UniServices = { oncreate() { document.title = "Uni-Dienste · FS Coli Portal" }, oninit() { lunchMenu.fetch() }, view() { return m( Base, m(LunchMenu, { items: lunchMenu.all ?.filter(it => it.category != "A+B") .map(it => it.name), message: lunchMenu.message, link: getMensaLink(), }), m("article.services", [ m( ServiceLink, Loading Loading @@ -71,14 +104,6 @@ export const UniServices = { "Uni-ID", ), ), m( ServiceLink, new Service( "Mensa INF", getMensaLink(), "fa-solid fa-utensils", ), ), ]), ) }, Loading portal/static/js/components/pieces/Agenda.mjs +2 −2 Original line number Diff line number Diff line export const Agenda = { view(vnode) { return m( "section.agenda.box", "section.agenda.fancy.box", m("section.content", [ m("h2", "Tagesordnung"), vnode.attrs.items Loading @@ -12,7 +12,7 @@ export const Agenda = { : m("span.message", vnode.attrs.message), ]), m( "a.edit", "a.action", { href: "https://fachschaft.cl.uni-heidelberg.de/todo", target: "_blank", Loading portal/static/js/components/pieces/LunchMenu.mjs 0 → 100644 +24 −0 Original line number Diff line number Diff line export const LunchMenu = { view(vnode) { return m( "section.lunch.fancy.box", m("section.content", [ m("h2", "Mittagessen Zentralmensa, INF 304"), vnode.attrs.items ? m( "ul", vnode.attrs.items.map(item => m("li", item)), ) : m("span.message", vnode.attrs.message), ]), m( "a.action", { href: vnode.attrs.link, target: "_blank", }, [m("i.fa-solid.fa-utensils"), "Ansehen beim Studierendenwerk"], ), ) }, } Loading
portal/static/css/main.css +14 −14 Original line number Diff line number Diff line Loading @@ -263,26 +263,26 @@ a.detail:hover { color: white; } /* ------------------------ Agenda ------------------------ */ /* ------------------------ Fancy boxes (agenda, lunch menu) ------------------------ */ .agenda { .fancy.box { margin: 0 auto; } .agenda > * { .fancy.box > * { padding: 1em; } .agenda h2 { .fancy.box h2 { margin-top: 0; } .agenda ol { .fancy.box ol { padding-left: 1.5em; margin: 0; } .agenda .edit { .fancy.box .action { display: grid; grid-template-columns: max-content max-content; text-decoration: none; Loading @@ -292,20 +292,20 @@ a.detail:hover { column-gap: 0.5em; } .agenda .edit > i { .fancy.box .action > i { font-size: 150%; } .agenda { .fancy.box { background: none; height: max-content; } .agenda:has(.edit:active) { .fancy.box:has(.action:active) { box-shadow: none; } .agenda .content { .fancy.box .content { background: radial-gradient( circle, rgb(255, 255, 255) 0%, Loading @@ -316,23 +316,23 @@ a.detail:hover { z-index: 2; } .agenda .content:has(+ .edit:active) { .fancy.box .content:has(+ .action:active) { box-shadow: var(--shadow-width) var(--shadow-width) 5px rgba(0, 0, 0, 0.5); } .agenda .edit { .fancy.box .action { background: rgba(255, 255, 255, 0.9); border-bottom-right-radius: 1em; border-bottom-left-radius: 1em; } .agenda .edit { .fancy.box .action { position: relative; top: 0; left: 0; } .agenda .edit:active { .fancy.box .action:active { box-shadow: none; left: 2px; top: 2px; Loading
portal/static/js/components/pages/UniServices.mjs +39 −14 Original line number Diff line number Diff line import { Service } from "../../model/Service.mjs" import { LunchMenu } from "../pieces/LunchMenu.mjs" import { ServiceLink } from "../pieces/ServiceLink.mjs" import { Base } from "./Base.mjs" Loading @@ -8,23 +9,55 @@ const germanDateFormatter = new Intl.DateTimeFormat("de-DE", { year: "numeric", }) /** * @returns the date the next lunch will likely be one (today, unless it is already afternoon, then tomorrow) */ function getNextLunchDate() { const nextLunchDate = new Date() if (nextLunchDate.getHours() >= 15) { // If it is 15:00 or later, next lunch will be tomorrow nextLunchDate.setDate(nextLunchDate.getDate() + 1) } return nextLunchDate } function getMensaLink() { const dayToShow = new Date() if (dayToShow.getHours() >= 15) { // If it is 15:00 or later, show tomorrow's menu dayToShow.setDate(dayToShow.getDate() + 1) return `https://www.stw.uni-heidelberg.de/external-tools/speiseplan/speiseplan.php?lang=de&mode=Mensa+Im+Neuenheimer+Feld+304&date=${germanDateFormatter.format(getNextLunchDate())}` } return `https://www.stw.uni-heidelberg.de/external-tools/speiseplan/speiseplan.php?lang=de&mode=Mensa+Im+Neuenheimer+Feld+304&date=${germanDateFormatter.format(dayToShow)}` const lunchMenu = { all: null, message: "Wird geladen...", async fetch() { try { this.all = await m.request({ method: "GET", url: `https://openmensa.org/api/v2/canteens/279/days/${getNextLunchDate().toISOString().split("T")[0]}/meals`, }) } catch (e) { this.message = "Das Menü konnte nicht geladen werden." } }, } export const UniServices = { oncreate() { document.title = "Uni-Dienste · FS Coli Portal" }, oninit() { lunchMenu.fetch() }, view() { return m( Base, m(LunchMenu, { items: lunchMenu.all ?.filter(it => it.category != "A+B") .map(it => it.name), message: lunchMenu.message, link: getMensaLink(), }), m("article.services", [ m( ServiceLink, Loading Loading @@ -71,14 +104,6 @@ export const UniServices = { "Uni-ID", ), ), m( ServiceLink, new Service( "Mensa INF", getMensaLink(), "fa-solid fa-utensils", ), ), ]), ) }, Loading
portal/static/js/components/pieces/Agenda.mjs +2 −2 Original line number Diff line number Diff line export const Agenda = { view(vnode) { return m( "section.agenda.box", "section.agenda.fancy.box", m("section.content", [ m("h2", "Tagesordnung"), vnode.attrs.items Loading @@ -12,7 +12,7 @@ export const Agenda = { : m("span.message", vnode.attrs.message), ]), m( "a.edit", "a.action", { href: "https://fachschaft.cl.uni-heidelberg.de/todo", target: "_blank", Loading
portal/static/js/components/pieces/LunchMenu.mjs 0 → 100644 +24 −0 Original line number Diff line number Diff line export const LunchMenu = { view(vnode) { return m( "section.lunch.fancy.box", m("section.content", [ m("h2", "Mittagessen Zentralmensa, INF 304"), vnode.attrs.items ? m( "ul", vnode.attrs.items.map(item => m("li", item)), ) : m("span.message", vnode.attrs.message), ]), m( "a.action", { href: vnode.attrs.link, target: "_blank", }, [m("i.fa-solid.fa-utensils"), "Ansehen beim Studierendenwerk"], ), ) }, }