LuminaWebsite/assets/js/reactions.js
Maaxxs c4f94bf84a Member feedback: raid input checks and fixed raid points, premades in the raid form, live raid page, Lumina-style dialogs, leadership calendar entries, class-based weapon picker, map and tactics fixes
- Raids: "Max. Spieler" only whole numbers up to groups x 5 (max. 10 groups / 50), gearscore only a number; fixed +1 Lumipunkt per participation, other values only with the new raids.points permission; pick an existing premade per group when creating a raid; unchanged legacy values no longer block editing
- Raid page updates itself every 15 s while visible (raids_live.php, cards rendered by includes/raid_card.php), open editors and confirm dialogs are kept
- Restore takes the new raid_id from the bot (archived messages are now deleted in Discord) and moves settings, attendance and awards; website signups send the server display name
- Premades: dissolve by leadership needs a reason, lead gets DMs on join/assign/decline/remove (source/actor_id sent to the bot), transfer picker skips players who already lead a group, website accept keeps the one-group rule, no commas in names
- Site-wide Lumina dialog (assets/js/confirm-dialog.js) replaces confirm/prompt/alert via data-confirm; error flashes are a dialog you confirm with OK
- Calendar: audience per entry (all / leadership takes part / internal) with the new calendar.leadership permission; day cells list all entries and scroll
- Gear planner: main-hand picker filtered by the set's class, mismatches marked, "keine Klasse" option, link to an external skill/Daevanion plan per set
- Map: correct kisk icons (Elyos on Verteron/Abyss, Altgard fixed), per-map max zoom and bounded panning, German texts, data source note
- Tactics: toolbar as a uniform grid, whole-tactic copy, automatic versions with restore and a 90-day trash, official tactics protected
- Global thin gold scrollbars, readable hover colours, "Sedes Luminis" spelling, patch notes and README, schema version 34

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 16:12:18 +02:00

71 lines
2.9 KiB
JavaScript

/**
* Reaktionen (Emojis) ohne Neuladen: Klick auf eine Reaktion oder ein Emoji in der Auswahl
* schickt das Formular im Hintergrund und ersetzt die Leiste durch die neue vom Server.
* Ohne JavaScript funktionieren die Formulare ganz normal (mit Neuladen).
*/
(function () {
'use strict';
document.addEventListener('submit', function (event) {
var form = event.target;
if (!form.classList || !form.classList.contains('reaction-form')) return;
event.preventDefault();
var bar = form.closest('.reaction-bar');
if (!bar || bar.classList.contains('is-busy')) return;
bar.classList.add('is-busy');
fetch(form.action, {
method: 'POST',
body: new FormData(form),
credentials: 'same-origin',
headers: { 'X-Requested-With': 'fetch', 'Accept': 'application/json' }
})
.then(function (response) { return response.json(); })
.then(function (data) {
if (!data.ok) {
window.luminaDialog.alert(data.error || 'Das hat nicht geklappt.', { tone: 'error' });
bar.classList.remove('is-busy');
return;
}
var wrapper = document.createElement('div');
wrapper.innerHTML = data.html;
var fresh = wrapper.firstElementChild;
if (fresh) {
bar.replaceWith(fresh);
var changed = fresh.querySelector('.reaction.is-mine');
if (changed) changed.classList.add('pop');
} else {
bar.remove();
}
})
.catch(function () {
bar.classList.remove('is-busy');
form.submit(); // Rueckfall: normal abschicken
});
});
// Emoji-Auswahl im Bild halten: ragt sie rechts hinaus, klappt sie nach links auf
document.addEventListener('toggle', function (event) {
var details = event.target;
if (!details.classList || !details.classList.contains('reaction-add') || !details.open) return;
var picker = details.querySelector('.reaction-picker');
picker.classList.remove('align-right');
if (picker.getBoundingClientRect().right > window.innerWidth - 8) {
picker.classList.add('align-right');
}
}, true);
// Emoji-Auswahl schliessen bei Klick daneben oder Escape
document.addEventListener('click', function (event) {
document.querySelectorAll('.reaction-add[open]').forEach(function (details) {
if (!details.contains(event.target)) details.removeAttribute('open');
});
});
document.addEventListener('keydown', function (event) {
if (event.key !== 'Escape') return;
document.querySelectorAll('.reaction-add[open]').forEach(function (details) {
details.removeAttribute('open');
});
});
})();