LuminaWebsite/assets/js/gear.js
Maaxxs 5dabbccbd7 Gear planner, dashboard polish, images on bug reports
Gear planner:
- Personal gear sets (18 slots) with enchant, exceed, soul imprint and manastones,
  stat totals by source and side-by-side comparison of 2-4 sets
- Sets can be shown on the own profile page (read-only for other members)
- Admin catalog: import items from aion2hub.com (Global client), compare stored
  values with the source one by one or all at once, at most one request per second
- New permissions gear.view (all with dashboard access) and gear.manage

Dashboard:
- Role badges ordered like the member list (roster_order)
- Stronger hover effect on "Rangliste & Verlauf" / "Zum Lumishop", no more blue
  hover on secondary buttons
- "Anstehende Raids" box links to the raids page, next raids link to the raid
  and to the calendar day
- Raid attendance only knows present/absent (old "excused" entries count as unset)

Bug reports:
- Up to 5 images per report, pasting copied images with Ctrl+V (also for the gallery)
- Images are only served to the reporter and bugs.manage via bug_image.php

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 09:27:09 +02:00

72 lines
3.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Gear-Planer (gear.php): Dialog "Set bearbeiten", Auswahl zum Vergleichen (2-4 Sets) und
* Hinweise zur Spanne der Seelenpraegung (Platzhalter + Pruefung beim Tippen).
*/
(function () {
'use strict';
// ---- Dialoge ----
document.querySelectorAll('[data-modal-open]').forEach(function (button) {
button.addEventListener('click', function () {
var modal = document.getElementById(button.dataset.modalOpen);
if (!modal) return;
modal.hidden = false;
var first = modal.querySelector('input[type="text"]');
if (first) first.focus();
});
});
document.querySelectorAll('.modal-overlay').forEach(function (modal) {
var close = modal.querySelector('.modal-close');
if (close) close.addEventListener('click', function () { modal.hidden = true; });
modal.addEventListener('click', function (event) {
if (event.target === modal) modal.hidden = true;
});
});
document.addEventListener('keydown', function (event) {
if (event.key !== 'Escape') return;
document.querySelectorAll('.modal-overlay:not([hidden])').forEach(function (modal) { modal.hidden = true; });
});
// ---- Vergleichen: 2 bis 4 Sets ----
var compareForm = document.getElementById('gear-compare-form');
var compareButton = document.getElementById('gear-compare-button');
if (compareForm && compareButton) {
var boxes = compareForm.querySelectorAll('input[name="compare[]"]');
var update = function () {
var checked = Array.prototype.filter.call(boxes, function (box) { return box.checked; }).length;
compareButton.disabled = checked < 2 || checked > 4;
compareButton.textContent = checked > 4 ? 'Höchstens 4 Sets' : 'Ausgewählte vergleichen' + (checked >= 2 ? ' (' + checked + ')' : '');
boxes.forEach(function (box) { box.closest('.gear-set-card').classList.toggle('is-checked', box.checked); });
};
boxes.forEach(function (box) { box.addEventListener('change', update); });
update();
}
// ---- Seelenpraegung: Spanne als Platzhalter, Wert ausserhalb markieren ----
function toNumber(value) {
return parseFloat(String(value).replace(/\./g, '').replace(',', '.'));
}
document.querySelectorAll('[data-range-select]').forEach(function (select) {
var input = select.parentNode.querySelector('input');
if (!input) return;
function sync() {
var option = select.options[select.selectedIndex];
var min = option && option.dataset.min;
var max = option && option.dataset.max;
var unit = option && option.dataset.unit ? ' %' : '';
input.placeholder = min ? String(min).replace('.', ',') + '–' + String(max).replace('.', ',') + unit : 'Wert';
input.required = !!min;
check();
}
function check() {
var option = select.options[select.selectedIndex];
var value = toNumber(input.value);
var bad = option && option.dataset.min && input.value.trim() !== ''
&& (isNaN(value) || value < parseFloat(option.dataset.min) || value > parseFloat(option.dataset.max));
input.setCustomValidity(bad ? 'Der Wert muss zwischen ' + input.placeholder + ' liegen.' : '');
}
select.addEventListener('change', sync);
input.addEventListener('input', check);
sync();
});
})();