From 6f59eadf2a42371e111de75ec696b0fd281647c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20M=C3=BChlberger?= Date: Tue, 21 Jul 2026 18:36:19 +0200 Subject: [PATCH] noch die html und js dateien. --- flarum-notifiy-v2.js | 135 +++++++++++++++++++++++++++++++++++++ flarum-notify-v2.html | 151 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 286 insertions(+) create mode 100644 flarum-notifiy-v2.js create mode 100644 flarum-notify-v2.html diff --git a/flarum-notifiy-v2.js b/flarum-notifiy-v2.js new file mode 100644 index 0000000..a11453d --- /dev/null +++ b/flarum-notifiy-v2.js @@ -0,0 +1,135 @@ +(function () { + 'use strict'; + + var forumOrigin = window.location.origin; + + function showTarget(targetValue) { + var targetUrl; + var forumLink; + var targetUrlLabel; + var postPanel; + var fallbackPanel; + + if (!targetValue) { + return false; + } + + try { + targetUrl = new URL(targetValue); + + if (targetUrl.origin !== forumOrigin) { + console.warn( + 'Rejected forum target with unexpected origin:', + targetUrl.origin + ); + + return false; + } + + if (targetUrl.pathname.indexOf('/d/') !== 0) { + console.warn( + 'Rejected forum target with unexpected path:', + targetUrl.pathname + ); + + return false; + } + + forumLink = document.getElementById('forum-link'); + targetUrlLabel = document.getElementById('target-url'); + postPanel = document.getElementById('post-panel'); + fallbackPanel = document.getElementById('fallback-panel'); + + if ( + !forumLink || + !targetUrlLabel || + !postPanel || + !fallbackPanel + ) { + console.warn( + 'Required landing-page elements were not found.' + ); + + return false; + } + + forumLink.href = targetUrl.href; + targetUrlLabel.textContent = targetUrl.href; + + postPanel.hidden = false; + fallbackPanel.hidden = true; + + return true; + } catch (error) { + console.warn( + 'The forum target URL is invalid.', + error + ); + + return false; + } + } + + async function initialize() { + var parameters; + var queryTarget; + var context; + var subPageId; + + parameters = new URLSearchParams( + window.location.search + ); + + queryTarget = parameters.get('target'); + + /* + * Allow direct browser tests with ?target=... + */ + if (showTarget(queryTarget)) { + return; + } + + /* + * In Microsoft Teams the target is passed as subEntityId. + * TeamsJS v2 exposes that value as context.page.subPageId. + */ + if ( + !window.microsoftTeams || + !window.microsoftTeams.app + ) { + console.info( + 'TeamsJS is unavailable; showing the notifications fallback.' + ); + + return; + } + + try { + await window.microsoftTeams.app.initialize(); + + context = + await window.microsoftTeams.app.getContext(); + + subPageId = + context && + context.page && + context.page.subPageId + ? context.page.subPageId + : null; + + console.info( + 'Teams page.subPageId:', + subPageId || '[none]' + ); + + showTarget(subPageId); + } catch (error) { + console.warn( + 'Could not read the Microsoft Teams context.', + error + ); + } + } + + initialize(); +})(); diff --git a/flarum-notify-v2.html b/flarum-notify-v2.html new file mode 100644 index 0000000..d19c237 --- /dev/null +++ b/flarum-notify-v2.html @@ -0,0 +1,151 @@ + + + + + sbp forum notifications + + + + + + +
+
+ + +

Forum activity notification

+ +

+ This Microsoft Teams app is a lightweight notifier. + It informs you about new activity in the sbp forum. +

+ + + +
+ How to continue:
+ Please open the forum directly to view and manage your notifications:
+ Open forum notifications +
+ +
+ Notifications are intentionally kept read-only in Microsoft Teams. +
+
+
+ + + + + +