2025-01-08 18:06:08 +01:00
|
|
|
function openDynamicPopup(subitem) {
|
2025-01-09 15:38:48 +01:00
|
|
|
// Schließe alle offenen Modals
|
|
|
|
closeAllModals();
|
|
|
|
|
2025-01-09 15:57:39 +01:00
|
|
|
// Setze den Titel mit Icon, falls vorhanden
|
|
|
|
const modalTitle = document.getElementById('dynamicModalLabel');
|
|
|
|
if (subitem.icon && subitem.icon.class) {
|
2025-01-09 16:30:38 +01:00
|
|
|
modalTitle.innerHTML = `<i class="${subitem.icon.class}"></i> ${subitem.name}`;
|
2025-01-09 15:57:39 +01:00
|
|
|
} else {
|
2025-01-09 16:30:38 +01:00
|
|
|
modalTitle.innerText = subitem.name;
|
2025-01-09 15:57:39 +01:00
|
|
|
}
|
2025-01-08 18:06:08 +01:00
|
|
|
|
2025-01-09 15:17:34 +01:00
|
|
|
// Setze den Identifier, falls vorhanden
|
2025-01-09 15:34:32 +01:00
|
|
|
const identifierBox = document.getElementById('dynamicIdentifierBox');
|
2025-01-09 15:17:34 +01:00
|
|
|
const modalContent = document.getElementById('dynamicModalContent');
|
|
|
|
if (subitem.identifier) {
|
2025-01-09 16:30:38 +01:00
|
|
|
identifierBox.classList.remove('d-none');
|
|
|
|
modalContent.value = subitem.identifier;
|
2025-01-09 15:17:34 +01:00
|
|
|
} else {
|
2025-01-09 16:30:38 +01:00
|
|
|
identifierBox.classList.add('d-none');
|
|
|
|
modalContent.value = '';
|
2025-01-09 15:17:34 +01:00
|
|
|
}
|
|
|
|
|
2025-01-09 16:30:38 +01:00
|
|
|
// Konfiguriere die Warnbox mit Markdown
|
2025-01-09 15:17:34 +01:00
|
|
|
const warningBox = document.getElementById('dynamicModalWarning');
|
|
|
|
if (subitem.warning) {
|
2025-01-09 16:30:38 +01:00
|
|
|
warningBox.classList.remove('d-none');
|
|
|
|
document.getElementById('dynamicModalWarningText').innerHTML = marked.parse(subitem.warning);
|
2025-01-09 15:17:34 +01:00
|
|
|
} else {
|
2025-01-09 16:30:38 +01:00
|
|
|
warningBox.classList.add('d-none');
|
2025-01-09 15:17:34 +01:00
|
|
|
}
|
|
|
|
|
2025-01-09 16:30:38 +01:00
|
|
|
// Konfiguriere die Infobox mit Markdown
|
2025-01-09 15:17:34 +01:00
|
|
|
const infoBox = document.getElementById('dynamicModalInfo');
|
|
|
|
if (subitem.info) {
|
2025-01-09 16:30:38 +01:00
|
|
|
infoBox.classList.remove('d-none');
|
|
|
|
document.getElementById('dynamicModalInfoText').innerHTML = marked.parse(subitem.info);
|
|
|
|
} else {
|
|
|
|
infoBox.classList.add('d-none');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Zeige die Beschreibung, falls keine URL vorhanden ist
|
|
|
|
const descriptionText = document.getElementById('dynamicDescriptionText');
|
|
|
|
if (!subitem.url && subitem.description) {
|
|
|
|
descriptionText.classList.remove('d-none');
|
|
|
|
descriptionText.innerText = subitem.description;
|
2025-01-09 15:17:34 +01:00
|
|
|
} else {
|
2025-01-09 16:30:38 +01:00
|
|
|
descriptionText.classList.add('d-none');
|
|
|
|
descriptionText.innerText = '';
|
2025-01-09 15:17:34 +01:00
|
|
|
}
|
|
|
|
|
2025-01-09 15:46:45 +01:00
|
|
|
// Konfiguriere den Link oder die Beschreibung
|
2025-01-09 15:17:34 +01:00
|
|
|
const linkBox = document.getElementById('dynamicModalLink');
|
|
|
|
const linkHref = document.getElementById('dynamicModalLinkHref');
|
|
|
|
if (subitem.url) {
|
2025-01-09 16:30:38 +01:00
|
|
|
linkBox.classList.remove('d-none');
|
|
|
|
linkHref.href = subitem.url;
|
|
|
|
linkHref.innerText = subitem.description || "Open Link";
|
2025-01-09 15:17:34 +01:00
|
|
|
} else {
|
2025-01-09 16:30:38 +01:00
|
|
|
linkBox.classList.add('d-none');
|
|
|
|
linkHref.href = '#';
|
2025-01-09 15:17:34 +01:00
|
|
|
}
|
|
|
|
|
2025-01-09 15:34:32 +01:00
|
|
|
// Konfiguriere die Alternativen
|
2025-01-09 15:57:39 +01:00
|
|
|
const alternativesSection = document.getElementById('dynamicAlternativesSection');
|
2025-01-09 15:34:32 +01:00
|
|
|
const alternativesList = document.getElementById('dynamicAlternativesList');
|
|
|
|
alternativesList.innerHTML = ''; // Clear existing alternatives
|
|
|
|
if (subitem.alternatives && subitem.alternatives.length > 0) {
|
2025-01-09 16:30:38 +01:00
|
|
|
alternativesSection.classList.remove('d-none');
|
|
|
|
subitem.alternatives.forEach(alt => {
|
|
|
|
const listItem = document.createElement('li');
|
|
|
|
listItem.classList.add('list-group-item', 'd-flex', 'justify-content-between', 'align-items-center');
|
|
|
|
listItem.innerHTML = `
|
|
|
|
<span>
|
|
|
|
<i class="${alt.icon.class}"></i> ${alt.name}
|
|
|
|
</span>
|
|
|
|
<button class="btn btn-outline-secondary btn-sm" onclick='openDynamicPopup(${JSON.stringify(alt)})'>Open</button>
|
|
|
|
`;
|
|
|
|
alternativesList.appendChild(listItem);
|
|
|
|
});
|
2025-01-09 15:34:32 +01:00
|
|
|
} else {
|
2025-01-09 16:30:38 +01:00
|
|
|
alternativesSection.classList.add('d-none');
|
2025-01-09 15:34:32 +01:00
|
|
|
}
|
|
|
|
|
2025-01-09 15:17:34 +01:00
|
|
|
// Kopierfunktion für den Identifier
|
|
|
|
document.getElementById('dynamicCopyButton').addEventListener('click', function () {
|
2025-01-09 16:30:38 +01:00
|
|
|
modalContent.select();
|
|
|
|
navigator.clipboard.writeText(modalContent.value).then(() => {
|
|
|
|
alert('Identifier copied to clipboard!');
|
|
|
|
});
|
2025-01-09 15:17:34 +01:00
|
|
|
});
|
2025-01-08 18:06:08 +01:00
|
|
|
|
2025-01-09 15:17:34 +01:00
|
|
|
// Modal anzeigen
|
|
|
|
const modal = new bootstrap.Modal(document.getElementById('dynamicModal'));
|
|
|
|
modal.show();
|
|
|
|
}
|
2025-01-09 15:38:48 +01:00
|
|
|
|
|
|
|
function closeAllModals() {
|
|
|
|
const modals = document.querySelectorAll('.modal.show'); // Alle offenen Modals finden
|
|
|
|
modals.forEach(modal => {
|
|
|
|
const modalInstance = bootstrap.Modal.getInstance(modal);
|
|
|
|
if (modalInstance) {
|
|
|
|
modalInstance.hide(); // Modal ausblenden
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Entferne die "modal-backdrop"-Elemente
|
|
|
|
const backdrops = document.querySelectorAll('.modal-backdrop');
|
|
|
|
backdrops.forEach(backdrop => backdrop.remove());
|
|
|
|
|
|
|
|
// Entferne die Klasse, die den Hintergrund ausgraut
|
|
|
|
document.body.classList.remove('modal-open');
|
|
|
|
document.body.style.overflow = '';
|
|
|
|
document.body.style.paddingRight = '';
|
|
|
|
}
|