Asked for: when the share for the Consilium ends, everyone from the Consilium is sent back to the live overview (so far only the live view ended and the map stayed open); during the session they may not switch maps or see the categories - really only the tactic. - map_frame.php: Consilium guests get the map viewer only for a running shared session (?karte=...&taktik=...), otherwise the whole page goes back to the session list; the viewer gets LUMINA_GUEST. - Viewer guest mode (body.guest-mode): no map picker, no markers or categories (not even loaded), no location sharing, no tactic list - only the tactic of the session (tactics_api.php ?taktik=). - When the share ends (relay event, tactic gone, no ticket), TacticController.endGuestSession() sends the top page to map.php?beendet=stopped|ended with a note why; the page around the map also checks every 15 s. - Calendar: no location picker for guests, meeting points are plain text for them (map_link_html()). - README, patch note text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
2.2 KiB
JavaScript
63 lines
2.2 KiB
JavaScript
/**
|
|
* TacticService - Laden und Speichern der Taktiken ueber die Website (tactics_api.php).
|
|
*
|
|
* Der Viewer laeuft im iframe von map.php auf derselben Domain: Anmeldung (Session-Cookie)
|
|
* und CSRF-Token kommen von der umgebenden Seite. Ausserhalb der Website - etwa als
|
|
* lokale Datei - gibt es den Endpunkt nicht, dann bleiben die Taktiken ausgeblendet.
|
|
*/
|
|
|
|
class TacticService {
|
|
constructor() {
|
|
this.endpoint = '/tactics_api.php';
|
|
}
|
|
|
|
csrfToken() {
|
|
try {
|
|
const meta = window.parent.document.querySelector('meta[name="csrf-token"]');
|
|
return meta ? meta.content : '';
|
|
} catch (e) {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
/** Taktiken einer Karte. tacticId: Gast des Consiliums - nur die Taktik seiner Sitzung. */
|
|
async list(slug, tacticId = null) {
|
|
const only = tacticId ? `&taktik=${encodeURIComponent(tacticId)}` : '';
|
|
const response = await fetch(`${this.endpoint}?map=${encodeURIComponent(slug)}${only}`, {
|
|
credentials: 'same-origin',
|
|
headers: { 'Accept': 'application/json' }
|
|
});
|
|
return this.parse(response);
|
|
}
|
|
|
|
async send(action, payload = {}) {
|
|
const response = await fetch(this.endpoint, {
|
|
method: 'POST',
|
|
credentials: 'same-origin',
|
|
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
|
|
body: JSON.stringify({ ...payload, action, csrf_token: this.csrfToken() })
|
|
});
|
|
return this.parse(response);
|
|
}
|
|
|
|
async parse(response) {
|
|
const text = await response.text();
|
|
let data;
|
|
try {
|
|
data = JSON.parse(text);
|
|
} catch (e) {
|
|
const error = new Error(text && response.status !== 404
|
|
? text.replace(/<[^>]*>/g, ' ').trim().slice(0, 200)
|
|
: 'Taktiken sind hier nicht verfügbar.');
|
|
error.unavailable = response.status === 404;
|
|
throw error;
|
|
}
|
|
|
|
if (data.status !== 'success') {
|
|
const error = new Error(data.message || 'Unbekannter Fehler.');
|
|
error.data = data;
|
|
throw error;
|
|
}
|
|
return data;
|
|
}
|
|
}
|