Loading portal/static/js/components/pages/UniServices.mjs +24 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,22 @@ import { Service } from "../../model/Service.mjs" import { ServiceLink } from "../pieces/ServiceLink.mjs" import { Base } from "./Base.mjs" const germanDateFormatter = new Intl.DateTimeFormat("de-DE", { month: "2-digit", day: "2-digit", year: "numeric", }) 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(dayToShow)}` } export const UniServices = { oncreate() { document.title = "Uni-Dienste · FS Coli Portal" Loading Loading @@ -46,6 +62,14 @@ export const UniServices = { "Uni-ID", ), ), m( ServiceLink, new Service( "Mensa INF", getMensaLink(), "fa-solid fa-utensils", ), ), ]), ) }, Loading Loading
portal/static/js/components/pages/UniServices.mjs +24 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,22 @@ import { Service } from "../../model/Service.mjs" import { ServiceLink } from "../pieces/ServiceLink.mjs" import { Base } from "./Base.mjs" const germanDateFormatter = new Intl.DateTimeFormat("de-DE", { month: "2-digit", day: "2-digit", year: "numeric", }) 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(dayToShow)}` } export const UniServices = { oncreate() { document.title = "Uni-Dienste · FS Coli Portal" Loading Loading @@ -46,6 +62,14 @@ export const UniServices = { "Uni-ID", ), ), m( ServiceLink, new Service( "Mensa INF", getMensaLink(), "fa-solid fa-utensils", ), ), ]), ) }, Loading