- impressum.php (§ 18 MStV) and datenschutz.php, which describes what the website and the Discord bot actually process: Discord login scopes, member area, bot data (raids, premades, player reports with the automatic 48 h timeout, activity checks), cookies and browser storage keys, retention periods and rights. Both stay reachable in maintenance mode and are noindex. Operator data defaults to the c/o address of the Impressum service Online-Impressum.de (LEGAL_OPERATOR_DEFAULT), the hoster to Living-Bots; both can be changed under Admin -> Impressum & Datenschutz (new permission site.legal, schema v43). The audit/Discord log only records which fields changed, not the name or address. - Links in the footer of all public pages, the start page footer, the sidebar and the maintenance page, plus a short data notice on the login page. - Wiki and profile texts: YouTube, Twitch and Vimeo players and images or video files from other servers render as placeholders and load only after a click (embed_consent_html(), assets/js/embed-consent.js). "immer direkt laden" is remembered per provider in localStorage and can be reset in the privacy policy. Image URLs are now protected from inline formatting (e.g. _underscores_ in the address). - map_frame.php only serves logged-in, active members. - Deleting a user also removes the avatar file; audit_log entries older than 12 months are deleted automatically (AUDIT_LOG_KEEP_MONTHS). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
160 lines
7.4 KiB
JavaScript
160 lines
7.4 KiB
JavaScript
/**
|
|
* Wiki-Editor: Formatierungs-Knoepfe, Live-Vorschau (vom Server gerendert, damit sie genau der
|
|
* spaeteren Seite entspricht), Bild-Upload und Warnung vor ungespeicherten Aenderungen.
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var form = document.getElementById('wiki-editor-form');
|
|
var area = document.getElementById('wiki-content');
|
|
var preview = document.getElementById('wiki-preview');
|
|
var previewToggle = document.getElementById('wiki-preview-toggle');
|
|
var imageInput = document.getElementById('wiki-image-input');
|
|
if (!form || !area) return;
|
|
|
|
var csrf = form.querySelector('input[name="csrf_token"]').value;
|
|
var initial = area.value;
|
|
var submitting = false;
|
|
|
|
function replaceSelection(before, after, placeholder) {
|
|
var start = area.selectionStart;
|
|
var end = area.selectionEnd;
|
|
var selected = area.value.slice(start, end) || placeholder || '';
|
|
area.setRangeText(before + selected + after, start, end, 'end');
|
|
// Platzhalter markieren, damit man ihn direkt ueberschreiben kann
|
|
if (!area.value.slice(start, end) && placeholder) {
|
|
area.setSelectionRange(start + before.length, start + before.length + selected.length);
|
|
}
|
|
area.focus();
|
|
area.dispatchEvent(new Event('input'));
|
|
}
|
|
|
|
function prefixLines(prefix) {
|
|
var start = area.value.lastIndexOf('\n', area.selectionStart - 1) + 1;
|
|
var end = area.selectionEnd;
|
|
var block = area.value.slice(start, end);
|
|
var lines = block.split('\n').map(function (line, i) {
|
|
var p = prefix === '1. ' ? (i + 1) + '. ' : prefix;
|
|
return line.indexOf(p) === 0 ? line : p + line;
|
|
});
|
|
area.setRangeText(lines.join('\n'), start, end, 'end');
|
|
area.focus();
|
|
area.dispatchEvent(new Event('input'));
|
|
}
|
|
|
|
function insertBlock(text) {
|
|
var pos = area.selectionStart;
|
|
var before = area.value.slice(0, pos);
|
|
var needsGap = before.length && !/\n\n$/.test(before) ? (/\n$/.test(before) ? '\n' : '\n\n') : '';
|
|
area.setRangeText(needsGap + text + '\n', pos, area.selectionEnd, 'end');
|
|
area.focus();
|
|
area.dispatchEvent(new Event('input'));
|
|
}
|
|
|
|
document.querySelector('.wiki-toolbar').addEventListener('click', function (e) {
|
|
var btn = e.target.closest('button');
|
|
if (!btn || btn === previewToggle) return;
|
|
if (btn.dataset.wrap) {
|
|
replaceSelection(btn.dataset.wrap, btn.dataset.wrap, 'Text');
|
|
} else if (btn.dataset.line) {
|
|
prefixLines(btn.dataset.line);
|
|
} else if (btn.dataset.insert === 'table') {
|
|
insertBlock('| Spalte 1 | Spalte 2 | Spalte 3 |\n| --- | --- | --- |\n| Wert | Wert | Wert |\n| Wert | Wert | Wert |');
|
|
} else if (btn.dataset.insert === 'link') {
|
|
window.luminaDialog.prompt('Adresse des Links (https://…):', { title: 'Link einfügen', value: 'https://', okLabel: 'Einfügen' }).then(function (url) {
|
|
area.focus();
|
|
if (url) replaceSelection('[', '](' + url.trim() + ')', 'Linktext');
|
|
});
|
|
} else if (btn.dataset.insert === 'wikilink') {
|
|
window.luminaDialog.prompt('Titel der Wiki-Seite, auf die verlinkt werden soll:', { title: 'Wiki-Link einfügen', okLabel: 'Einfügen' }).then(function (title) {
|
|
area.focus();
|
|
if (title) replaceSelection('', '', '[[' + title.trim() + ']]');
|
|
});
|
|
} else if (btn.dataset.insert === 'image') {
|
|
imageInput.click();
|
|
} else if (btn.dataset.insert === 'video') {
|
|
window.luminaDialog.prompt('Link zum Video - YouTube, Twitch (Clip oder Video), Vimeo oder eine Videodatei (.mp4/.webm):', { title: 'Video einfügen', value: 'https://', okLabel: 'Einfügen' }).then(function (video) {
|
|
area.focus();
|
|
if (video && /^https?:\/\/\S+$/.test(video.trim())) {
|
|
// Allein in einer Zeile wird der Link zum eingebetteten Player
|
|
insertBlock(video.trim());
|
|
} else if (video && video.trim() !== 'https://') {
|
|
window.luminaDialog.alert('Das sieht nicht nach einem Link aus. Bitte die komplette Adresse einfügen (https://…).', { tone: 'error' });
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
area.addEventListener('keydown', function (e) {
|
|
if (!(e.ctrlKey || e.metaKey)) return;
|
|
if (e.key === 'b' || e.key === 'B') {
|
|
e.preventDefault();
|
|
replaceSelection('**', '**', 'Text');
|
|
} else if (e.key === 'i' || e.key === 'I') {
|
|
e.preventDefault();
|
|
replaceSelection('*', '*', 'Text');
|
|
}
|
|
});
|
|
|
|
// Bild hochladen und an der Cursorposition einfuegen
|
|
imageInput.addEventListener('change', function () {
|
|
var file = imageInput.files && imageInput.files[0];
|
|
if (!file) return;
|
|
var data = new FormData();
|
|
data.append('action', 'upload');
|
|
data.append('csrf_token', csrf);
|
|
data.append('image', file);
|
|
var marker = '![Bild wird hochgeladen …]()';
|
|
insertBlock(marker);
|
|
fetch('/wiki_action.php', { method: 'POST', body: data, credentials: 'same-origin' })
|
|
.then(function (r) { return r.json(); })
|
|
.then(function (res) {
|
|
var replacement = res.ok ? '![' + file.name.replace(/\.[^.]+$/, '') + '](' + res.url + ')' : '';
|
|
area.value = area.value.replace(marker, replacement);
|
|
if (!res.ok) window.luminaDialog.alert(res.message || 'Upload fehlgeschlagen.', { tone: 'error' });
|
|
area.dispatchEvent(new Event('input'));
|
|
})
|
|
.catch(function () {
|
|
area.value = area.value.replace(marker, '');
|
|
window.luminaDialog.alert('Upload fehlgeschlagen.', { tone: 'error' });
|
|
});
|
|
imageInput.value = '';
|
|
});
|
|
|
|
// Vorschau: vom Server rendern lassen (gleiche Darstellung wie spaeter auf der Seite)
|
|
var previewTimer = 0;
|
|
function renderPreview() {
|
|
var data = new FormData();
|
|
data.append('action', 'preview');
|
|
data.append('csrf_token', csrf);
|
|
data.append('content', area.value);
|
|
fetch('/wiki_action.php', { method: 'POST', body: data, credentials: 'same-origin' })
|
|
.then(function (r) { return r.json(); })
|
|
.then(function (res) {
|
|
preview.innerHTML = res.ok && res.html.trim() !== '' ? res.html : '<p class="text-muted">Noch nichts zu sehen.</p>';
|
|
// Videos/Bilder freigegebener Anbieter gleich laden (assets/js/embed-consent.js)
|
|
if (window.luminaEmbeds) window.luminaEmbeds.scan(preview);
|
|
});
|
|
}
|
|
previewToggle.addEventListener('click', function () {
|
|
var on = preview.hidden;
|
|
preview.hidden = !on;
|
|
previewToggle.setAttribute('aria-pressed', String(on));
|
|
form.classList.toggle('wiki-editor-split', on);
|
|
if (on) renderPreview();
|
|
});
|
|
area.addEventListener('input', function () {
|
|
if (preview.hidden) return;
|
|
window.clearTimeout(previewTimer);
|
|
previewTimer = window.setTimeout(renderPreview, 400);
|
|
});
|
|
|
|
// Nicht versehentlich ungespeicherte Aenderungen verlieren
|
|
form.addEventListener('submit', function () { submitting = true; });
|
|
window.addEventListener('beforeunload', function (e) {
|
|
if (!submitting && area.value !== initial) {
|
|
e.preventDefault();
|
|
e.returnValue = '';
|
|
}
|
|
});
|
|
})();
|