LuminaWebsite/assets/js/premades.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

149 lines
6.7 KiB
JavaScript

(function () {
'use strict';
function openModal(modal) {
if (modal) modal.hidden = false;
}
function closeModal(modal) {
if (modal) modal.hidden = true;
}
function wireModal(modal) {
if (!modal) return;
var closeBtn = modal.querySelector('.modal-close');
if (closeBtn) closeBtn.addEventListener('click', function () { closeModal(modal); });
modal.addEventListener('click', function (e) {
if (e.target === modal) closeModal(modal);
});
}
// ---- Bearbeiten-Modus pro Premade (bleibt nach dem Neuladen durch eine Aktion offen) ----
var EDIT_KEY = 'premades-editing';
function loadEditing() {
try { return JSON.parse(sessionStorage.getItem(EDIT_KEY) || '[]'); } catch (e) { return []; }
}
function saveEditing(ids) {
try { sessionStorage.setItem(EDIT_KEY, JSON.stringify(ids)); } catch (e) { /* egal */ }
}
var editingIds = loadEditing();
document.querySelectorAll('.premade-panel').forEach(function (panel) {
var toggle = panel.querySelector('.premade-edit-toggle');
if (!toggle) return;
var id = panel.getAttribute('data-premade-id');
function setEditing(on) {
panel.classList.toggle('is-editing', on);
toggle.setAttribute('aria-pressed', on ? 'true' : 'false');
toggle.title = on ? 'Bearbeiten beenden' : 'Premade bearbeiten';
}
setEditing(editingIds.indexOf(id) !== -1);
toggle.addEventListener('click', function () {
var on = !panel.classList.contains('is-editing');
setEditing(on);
editingIds = editingIds.filter(function (x) { return x !== id; });
if (on) editingIds.push(id);
saveEditing(editingIds);
});
});
// ---- Mitglied einladen ----
var inviteModal = document.getElementById('premade-invite-modal');
var inviteForm = document.getElementById('premade-invite-form');
var invitePremadeIdField = document.getElementById('premade-invite-premade-id');
var inviteUserIdField = document.getElementById('premade-invite-user-id');
wireModal(inviteModal);
// Die Leitung teilt direkt ein (data-direct="1"), ein Lead verschickt eine Einladung.
var inviteDirect = false;
document.querySelectorAll('.premade-slot-invite-btn').forEach(function (btn) {
btn.addEventListener('click', function () {
invitePremadeIdField.value = btn.getAttribute('data-premade-id') || '';
inviteDirect = btn.getAttribute('data-direct') === '1';
// Nur Spieler zeigen, die in genau diese Gruppe passen
var allowed = (btn.getAttribute('data-candidates') || '').split(',');
if (inviteModal) {
inviteModal.querySelectorAll('.premade-invite-option').forEach(function (option) {
option.hidden = allowed.indexOf(option.getAttribute('data-user-id')) === -1;
});
var title = inviteModal.querySelector('.premade-invite-title');
var hint = inviteModal.querySelector('.premade-invite-hint');
if (title) title.textContent = inviteDirect ? 'Spieler einteilen' : 'Mitglied einladen';
if (hint) hint.textContent = hint.getAttribute(inviteDirect ? 'data-direct-text' : 'data-invite-text');
}
openModal(inviteModal);
});
});
if (inviteModal) {
inviteModal.querySelectorAll('.premade-invite-option').forEach(function (btn) {
btn.addEventListener('click', function () {
// Die Auswahl verschickt sofort eine Discord-PN - deshalb vorher nachfragen.
var name = btn.getAttribute('data-user-name') || 'dieses Mitglied';
var question = inviteDirect
? name + ' wirklich in die Premade einteilen?\n\nDas Mitglied wird per Discord-PN benachrichtigt.'
: name + ' wirklich in die Premade einladen?\n\nDas Mitglied wird per Discord-PN benachrichtigt.';
window.luminaDialog.confirm(question, {
title: inviteDirect ? 'Spieler einteilen' : 'Mitglied einladen',
okLabel: inviteDirect ? 'Einteilen' : 'Einladen'
}).then(function (ok) {
if (!ok) return;
inviteUserIdField.value = btn.getAttribute('data-user-id') || '';
inviteForm.submit();
});
});
});
}
// ---- Aufloesen durch die Leitung (mit Begruendung fuer den Lead) ----
var dissolveModal = document.getElementById('premade-dissolve-modal');
wireModal(dissolveModal);
if (dissolveModal) {
var dissolveCancel = dissolveModal.querySelector('.modal-cancel');
if (dissolveCancel) dissolveCancel.addEventListener('click', function () { closeModal(dissolveModal); });
}
document.querySelectorAll('.premade-dissolve-btn').forEach(function (btn) {
btn.addEventListener('click', function () {
if (!dissolveModal) return;
document.getElementById('premade-dissolve-premade-id').value = btn.getAttribute('data-premade-id') || '';
dissolveModal.querySelector('.premade-dissolve-name').textContent = btn.getAttribute('data-premade-name') || '';
var reason = document.getElementById('premade-dissolve-reason');
reason.value = '';
openModal(dissolveModal);
reason.focus();
});
});
// ---- Klasse festlegen/aendern ----
var classModal = document.getElementById('premade-class-modal');
var classForm = document.getElementById('premade-class-form');
var classPremadeIdField = document.getElementById('premade-class-premade-id');
var classValueField = document.getElementById('premade-class-value');
wireModal(classModal);
document.querySelectorAll('.premade-class-action').forEach(function (btn) {
btn.addEventListener('click', function () {
classPremadeIdField.value = btn.getAttribute('data-premade-id') || '';
var currentClass = btn.getAttribute('data-current-class') || '';
if (classModal) {
classModal.querySelectorAll('.class-picker-option').forEach(function (option) {
option.classList.toggle('selected', option.getAttribute('data-class') === currentClass);
});
}
openModal(classModal);
});
});
if (classModal) {
classModal.querySelectorAll('.class-picker-option').forEach(function (btn) {
btn.addEventListener('click', function () {
classValueField.value = btn.getAttribute('data-class') || '';
classForm.submit();
});
});
}
})();