<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Arrays in Modal anzeigen</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
            background-color: #f5f5f5;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }

        .btn {
            background-color: #007bff;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            margin: 5px;
            font-size: 16px;
        }

        .btn:hover {
            background-color: #0056b3;
        }

        /* Modal Styles */
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.5);
        }

        .modal-content {
            background-color: #fefefe;
            margin: 5% auto;
            padding: 20px;
            border: none;
            border-radius: 8px;
            width: 80%;
            max-width: 600px;
            max-height: 80vh;
            overflow-y: auto;
            position: relative;
        }

        .modal-buttons {
            text-align: center;
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #dee2e6;
        }

        .btn-correct {
            background-color: #dc3545;
            color: white;
            padding: 12px 25px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            margin: 0 10px;
            font-size: 16px;
        }

        .btn-correct:hover {
            background-color: #c82333;
        }

        .btn-publish {
            background-color: #28a745;
            color: white;
            padding: 12px 25px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            margin: 0 10px;
            font-size: 16px;
        }

        .btn-publish:hover {
            background-color: #218838;
        }

        .array-container {
            margin-bottom: 20px;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 5px;
            border-left: 4px solid #007bff;
        }

        .array-title {
            font-weight: bold;
            color: #333;
            margin-bottom: 10px;
            font-size: 18px;
        }

        .array-content {
            background-color: white;
            padding: 10px;
            border-radius: 4px;
            border: 1px solid #dee2e6;
        }

        .array-item {
            padding: 5px 0;
            border-bottom: 1px solid #eee;
        }

        .array-item:last-child {
            border-bottom: none;
        }

        .array-index {
            color: #666;
            font-weight: bold;
            display: inline-block;
            width: 40px;
        }

        .object-property {
            margin-left: 20px;
            color: #495057;
        }

        .key {
            color: #007bff;
            font-weight: bold;
        }

        .value {
            color: #28a745;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Arrays in Modal-Fenster anzeigen</h1>
        <p>Klicken Sie auf einen Button, um die entsprechenden Arrays im Modal anzuzeigen:</p>
        
        <button class="btn" onclick="showArraysModal('fruits')">Früchte Arrays</button>
        <button class="btn" onclick="showArraysModal('users')">Benutzer Arrays</button>
        <button class="btn" onclick="showArraysModal('mixed')">Gemischte Arrays</button>
        <button class="btn" onclick="showArraysModal('all')">Alle Arrays</button>
    </div>

    <!-- Modal -->
    <div id="arrayModal" class="modal">
        <div class="modal-content">
            <div id="modalBody">
                <!-- Arrays werden hier angezeigt -->
            </div>
            <div class="modal-buttons">
                <button class="btn-correct" onclick="correctData()">Angaben korrigieren</button>
                <button class="btn-publish" onclick="finishPublication()">Publikation abschließen</button>
            </div>
        </div>
    </div>

    <script>
        // Beispiel-Arrays definieren
        const dataArrays = {
            fruits: {
                simple: ['Apfel', 'Banane', 'Orange', 'Erdbeere', 'Kiwi'],
                exotic: ['Mango', 'Papaya', 'Drachenfrucht', 'Litschi'],
                seasonal: ['Erdbeeren', 'Kirschen', 'Pfirsiche', 'Pflaumen']
            },
            users: {
                names: ['Anna', 'Max', 'Lisa', 'Tom', 'Sarah'],
                profiles: [
                    { name: 'Anna', age: 28, city: 'Berlin' },
                    { name: 'Max', age: 34, city: 'München' },
                    { name: 'Lisa', age: 25, city: 'Hamburg' },
                    { name: 'Tom', age: 31, city: 'Köln' }
                ],
                roles: ['Admin', 'User', 'Moderator', 'Guest']
            },
            mixed: {
                numbers: [1, 5, 10, 15, 20, 25],
                booleans: [true, false, true, true, false],
                mixed: ['Text', 42, true, null, { key: 'value' }]
            }
        };

        function showArraysModal(category) {
            const modal = document.getElementById('arrayModal');
            const modalBody = document.getElementById('modalBody');
            
            // Modal-Inhalt leeren
            modalBody.innerHTML = '';
            
            let arraysToShow = {};
            
            if (category === 'all') {
                // Alle Arrays anzeigen
                arraysToShow = dataArrays;
            } else {
                // Nur die ausgewählte Kategorie
                arraysToShow[category] = dataArrays[category];
            }
            
            // Titel hinzufügen
            const title = document.createElement('h2');
            title.textContent = category === 'all' ? 'Alle Arrays' : getCategoryTitle(category);
            title.style.marginBottom = '20px';
            title.style.color = '#333';
            modalBody.appendChild(title);
            
            // Arrays durchgehen und anzeigen
            for (const [categoryName, categoryArrays] of Object.entries(arraysToShow)) {
                if (category === 'all') {
                    const categoryTitle = document.createElement('h3');
                    categoryTitle.textContent = getCategoryTitle(categoryName);
                    categoryTitle.style.color = '#007bff';
                    categoryTitle.style.marginTop = '30px';
                    categoryTitle.style.marginBottom = '15px';
                    modalBody.appendChild(categoryTitle);
                }
                
                for (const [arrayName, arrayData] of Object.entries(categoryArrays)) {
                    createArrayDisplay(modalBody, arrayName, arrayData);
                }
            }
            
            // Modal anzeigen
            modal.style.display = 'block';
        }

        function createArrayDisplay(container, arrayName, arrayData) {
            const arrayContainer = document.createElement('div');
            arrayContainer.className = 'array-container';
            
            const arrayTitle = document.createElement('div');
            arrayTitle.className = 'array-title';
            arrayTitle.textContent = `${arrayName} (${arrayData.length} Elemente)`;
            arrayContainer.appendChild(arrayTitle);
            
            const arrayContent = document.createElement('div');
            arrayContent.className = 'array-content';
            
            arrayData.forEach((item, index) => {
                const itemDiv = document.createElement('div');
                itemDiv.className = 'array-item';
                
                const indexSpan = document.createElement('span');
                indexSpan.className = 'array-index';
                indexSpan.textContent = `[${index}]`;
                itemDiv.appendChild(indexSpan);
                
                if (typeof item === 'object' && item !== null) {
                    // Objekt anzeigen
                    const objectDiv = document.createElement('div');
                    objectDiv.style.display = 'inline-block';
                    
                    for (const [key, value] of Object.entries(item)) {
                        const propDiv = document.createElement('div');
                        propDiv.className = 'object-property';
                        propDiv.innerHTML = `<span class="key">${key}:</span> <span class="value">${JSON.stringify(value)}</span>`;
                        objectDiv.appendChild(propDiv);
                    }
                    itemDiv.appendChild(objectDiv);
                } else {
                    // Einfacher Wert
                    const valueSpan = document.createElement('span');
                    valueSpan.className = 'value';
                    valueSpan.textContent = JSON.stringify(item);
                    itemDiv.appendChild(valueSpan);
                }
                
                arrayContent.appendChild(itemDiv);
            });
            
            arrayContainer.appendChild(arrayContent);
            container.appendChild(arrayContainer);
        }

        function getCategoryTitle(category) {
            const titles = {
                fruits: 'Früchte Arrays',
                users: 'Benutzer Arrays',
                mixed: 'Gemischte Arrays'
            };
            return titles[category] || category;
        }

        function correctData() {
            // Hier können Sie die Logik für "Angaben korrigieren" implementieren
            alert('Angaben werden zur Korrektur geöffnet...');
            closeModal();
        }

        function finishPublication() {
            // Hier können Sie die Logik für "Publikation abschließen" implementieren
            alert('Publikation wird abgeschlossen...');
            closeModal();
        }

        function closeModal() {
            document.getElementById('arrayModal').style.display = 'none';
        }

        // ESC-Taste und Klick außerhalb deaktiviert - Modal kann nur über Buttons geschlossen werden
    </script>
</body>
</html>
