Refactored warning and info js

This commit is contained in:
Kevin Veen-Birkenbach 2025-01-17 01:07:48 +01:00
parent a0664691e6
commit 0f8113974f

View File

@ -17,21 +17,18 @@ function openDynamicPopup(subitem) {
modalContent.value = ''; modalContent.value = '';
} }
const warningBox = document.getElementById('dynamicModalWarning'); function toggleBox(boxId, textId, content) {
if (subitem.warning) { const box = document.getElementById(boxId);
warningBox.classList.remove('d-none'); if (content) {
document.getElementById('dynamicModalWarningText').innerHTML = marked.parse(subitem.warning); box.classList.remove('d-none');
document.getElementById(textId).innerHTML = marked.parse(content);
} else { } else {
warningBox.classList.add('d-none'); box.classList.add('d-none');
}
} }
const infoBox = document.getElementById('dynamicModalInfo'); toggleBox('dynamicModalWarning', 'dynamicModalWarningText', subitem.warning);
if (subitem.info) { toggleBox('dynamicModalInfo', 'dynamicModalInfoText', subitem.info);
infoBox.classList.remove('d-none');
document.getElementById('dynamicModalInfoText').innerHTML = marked.parse(subitem.info);
} else {
infoBox.classList.add('d-none');
}
const descriptionText = document.getElementById('dynamicDescriptionText'); const descriptionText = document.getElementById('dynamicDescriptionText');
if (!subitem.url && subitem.description) { if (!subitem.url && subitem.description) {