From fccb70cbd876785f6833dfe6efc10ec9e445556d Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 3 Aug 2026 11:32:38 +0200 Subject: fixup! misc commit --- js/utils-common.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 js/utils-common.js (limited to 'js/utils-common.js') diff --git a/js/utils-common.js b/js/utils-common.js new file mode 100644 index 0000000..8e4cfac --- /dev/null +++ b/js/utils-common.js @@ -0,0 +1,20 @@ +export const DATE_FMT = new Intl.DateTimeFormat("de-DE", { month: "numeric", day: "numeric", year: "numeric"}); + +export const DATETIME_FMT = new Intl.DateTimeFormat("de-DE", { month: "numeric", day: "numeric", year: "numeric", hour: "numeric", minute: "numeric" }); + +export function dateStringNow() { + return DATE_FMT.format(new Date()); +} + +export function datetimeStringNow() { + return DATETIME_FMT.format(new Date()); +} + +// TODO(muhq): Cache the retrieved URL +export async function getUserIconUrl(userId) { + console.assert(userId, "getUserIconUrl needs a userId"); + const userRes = await fetch(`https://lernplattform.bycs.de/user/profile.php?id=${userId}`) + const userDoc = new DOMParser().parseFromString(await userRes.text(), 'text/html') + const userpicture = userDoc.querySelector(".userpicture"); + return userpicture ? userpicture.src : ""; +} -- cgit v1.2.3