Benutzer:T1qj7p/Testseite2
<section class="figure-section" data-figure data-cols="5" data-rows="2">
Heftchenblatt 8 Y II RLV V
Deutsche Bundespost · 5×2 Felder (linker Leerrand nicht gezählt)
Kombinationen
</section>
<section class="figure-section" data-figure data-cols="5" data-rows="2">
Heftchenblatt 8 Y II RLV V
Deutsche Bundespost · 5×2 Felder (linker Leerrand nicht gezählt)
<img src="Bund_HBlatt_8_Y_II_RLV_V.jpg" alt="Briefmarken-Heftchenblatt">
Kombinationen
</section>
ID-Format:XYdN— X = Spalte, Y = Zeile, d =w(waagerecht) oders(senkrecht), N = Anzahl Felder. Ursprung (1,1) = oben links (linker Rand nicht gezählt).
<script>
// ════════════════════════════════════════════════════════════════
// Feldkoordinaten in Prozent (automatisch aus dem Bild vermessen)
// Format: { "col_row": { left, top, width, height } } (alle in %)
// ════════════════════════════════════════════════════════════════
const FIELD_COORDS = {
"1_1": { left: 10.62, top: 6.22, width: 15.58, height: 41.06 },
"2_1": { left: 28.43, top: 6.22, width: 15.62, height: 41.06 },
"3_1": { left: 46.30, top: 6.22, width: 15.62, height: 41.06 },
"4_1": { left: 64.11, top: 6.22, width: 15.65, height: 41.06 },
"5_1": { left: 81.95, top: 6.22, width: 15.62, height: 41.06 },
"1_2": { left: 10.62, top: 52.80, width: 15.58, height: 40.83 },
"2_2": { left: 28.43, top: 52.80, width: 15.62, height: 40.83 },
"3_2": { left: 46.30, top: 52.80, width: 15.62, height: 40.83 },
"4_2": { left: 64.11, top: 52.80, width: 15.65, height: 40.83 },
"5_2": { left: 81.95, top: 52.80, width: 15.62, height: 40.83 },
};
// ════════════════════════════════════════════════════════════════ // Overlays in den Bild-Container einfügen // ════════════════════════════════════════════════════════════════ const container = document.getElementById('fig1-container');
Object.entries(FIELD_COORDS).forEach(([key, pos]) => {
const overlay = document.createElement('div');
overlay.className = 'overlay';
overlay.dataset.field = key;
overlay.style.left = pos.left + '%';
overlay.style.top = pos.top + '%';
overlay.style.width = pos.width + '%';
overlay.style.height = pos.height + '%';
container.appendChild(overlay);
});
// ════════════════════════════════════════════════════════════════ // ID parsen → betroffene Felder bestimmen // ════════════════════════════════════════════════════════════════ function parseCombinationId(id) {
const match = id.match(/(\d)(\d)([ws])(\d)$/); if (!match) return []; const startCol = parseInt(match[1]); const startRow = parseInt(match[2]); const dir = match[3]; const count = parseInt(match[4]);
const keys = [];
for (let i = 0; i < count; i++) {
const col = dir === 'w' ? startCol + i : startCol;
const row = dir === 's' ? startRow + i : startRow;
keys.push(`${col}_${row}`);
}
return keys;
}
// ════════════════════════════════════════════════════════════════ // Hover-Events // ════════════════════════════════════════════════════════════════ document.querySelectorAll('.combos > div[id]').forEach(comboEl => {
const fieldKeys = parseCombinationId(comboEl.id);
// Label voranstellen
const shortId = comboEl.id.includes('-') ? comboEl.id.split('-').slice(1).join('-') : comboEl.id;
const label = document.createElement('span');
label.className = 'combo-label';
label.textContent = shortId;
comboEl.prepend(label);
// Warnung wenn Felder nicht gefunden
const overlays = fieldKeys.map(k => container.querySelector(`.overlay[data-field="${k}"]`)).filter(Boolean);
if (overlays.length === 0) {
comboEl.style.borderColor = '#e05a2b';
comboEl.title = `⚠ Felder konnten nicht aufgelöst werden`;
}
comboEl.addEventListener('mouseenter', () => {
overlays.forEach(o => o.classList.add('highlighted'));
comboEl.classList.add('active');
});
comboEl.addEventListener('mouseleave', () => {
overlays.forEach(o => o.classList.remove('highlighted'));
comboEl.classList.remove('active');
});
}); </script>
-->

